Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
247 views

find and rename base directory and files under each basedir, add a prefix

I would like to recursively rename all matching directories and files under a path with a prefix that depend from the current directory. . ├── G1_BIN_REFINEMENT │   └── marker_genes │   └── ...
user1967473's user avatar
1 vote
1 answer
692 views

How to tell which files are new or have been modified between calls of a script

I want to call a shell script regularly, and in it I need to process the files present in a directory tree that are new or that have been modified since the previous call of the script. My 1st thought ...
dargaud's user avatar
  • 220
2 votes
1 answer
859 views

List only bottom level directories using find

So, let's say I use find to search a directory for folders. find "/home/user/Documents" -type d -print While this does list all the directories in said location, I only want to get the ...
Eduardo Perez's user avatar
1 vote
2 answers
488 views

Cygwin find returns "missing argument to `-exec'"

I have backups script that removes backups older than x days. On Linux machine this is working well: find /backups/dummy-prod-db -name "*_D_dummy-prod-db*" -type f -mtime +7 -exec rm -v {} \;...
Kamil's user avatar
  • 2,666
11 votes
1 answer
642 views

In bash, how to find all copies of a given file in particular directories?

Let's say we have a file /a_long_path_1/foo.doc of size, say, 12345 bytes, and we would like to find all copies of this file in directories /a_long_path_2 and /a_long_path_3 including all their ...
user avatar
2 votes
1 answer
2k views

Bash find using regex fails with digit matching

I'm using find (GNU findutils) 4.7.0 with GNU bash, version 5.0.17. touch hello.32.world.txt find . # works, output is: ./hello.32.world.txt find . -regextype posix-extended -regex '.*hello\.32\.world\...
Andrew Parks's user avatar
0 votes
1 answer
442 views

Move and rename files based on their parent folders

I'm trying to write a Bash function that will find files in a given directory tree and move them to the current folder while renaming them based on their parent folder, but I'm still stuck on the ...
Hashim Aziz's user avatar
0 votes
1 answer
459 views

How to do a recursive filename `find` from the shell using a glob pattern with "set braces"

From the shell, I'd like to recursively search a directory for a given glob pattern. But I want to use set-braces-syntax in my pattern: find ~/path/to/dir -name '*.{h,m}' Here I'd like to recursively ...
Todd Ditchendorf's user avatar
1 vote
0 answers
2k views

Can I use regex in find path?

env = bash, centos7 My goal is to delete jenkins workspace cache files under specific path, except for today's. Successful command : cd /jenkins/jenkins/workspace/CMSvc_Build/caches/modules-2/files-2....
Lunartist's user avatar
  • 159
0 votes
0 answers
160 views

Calling exiftool on a huge number of recovered images from photorec

I am trying to recover images of the last 20 years from a friend. She moved all recent files to trash, then emptied the trash. Those images were lying on the system partition, so photorec found a huge ...
dwn's user avatar
  • 101
0 votes
1 answer
4k views

List all sub-directories with a specific pattern in bash and execute a command

I have a directory like this: . ./foo/.bar/bar/file.jpg ./foo/.bar/xyw/dummy.fil ./foo3/.bar/file.jpg ./foo3/.bar/bar/file.jpg ./fo/bar/file.jpg I'm trying to list all subdirectories that contain the ...
amsou's user avatar
  • 3
0 votes
1 answer
274 views

search over all drives in git bash crashes - "failed to read file names from file system at or below '/': No such file or directory"

I am using the git-bash for windows (what is internal msys2). I needed to search over all of my harddrives. When I try to run find / -type d (and my search patterns), the search runs over the system ...
Radon8472's user avatar
  • 801
1 vote
1 answer
344 views

regex in find doesn't accept the or operator in group

I'm trying to delete all files and directories in a parent directory, with the exclusion of some directories and their content. For this I use find in a bash script on MacOS. It works if I exclude ...
Philipp's user avatar
  • 13
0 votes
2 answers
659 views

How to delete any files that have not been used (access, change or modify) in X years

i run this command find BAR -type f -mtime +1095 # older than 3 years and find this file: BAR/foo.pdf So i run this: stat BAR/foo.pdf Access: 2020-01-03 01:32:05.584393000 -0500 Modification: 2017-...
acgbox's user avatar
  • 785
0 votes
1 answer
408 views

Find the most recent file of a type in terminal and then open it (mac os)

I found part of this question in 2 other posted questions, but I cant seem to get the last step working which is just "opening" the file: How do I get files found by command-line 'find&#...
Mix Lab Tech's user avatar
1 vote
1 answer
33 views

using find in bash to operate of filles based on their extension patterns

I am using "find" command to delete some useless filles of the given extensions from all subfolders located in the directory from which I am executing the command. find -type f -name *.txt -...
Hot JAMS's user avatar
  • 147
4 votes
1 answer
684 views

Subshell won't work as indented

I have some files like this: ├── abc.conf ├── def.conf ├── xyz.conf ├── 10-abc.conf.postix ├── 10-def.conf.postix and I want to remove the .postfix from all files which starts with 10-. To do this ...
akop's user avatar
  • 143
0 votes
2 answers
2k views

find -exec with wildcard

I am trying to use bash 'find' to process all folders that contain a .log file and get their sizes. However the wildcard is not working as expected. This returns nothing: find . -type d -exec test -e ...
WiringHarness's user avatar
1 vote
2 answers
178 views

Generalized chmod function differentiating between directories and files (i.e.: with find)

Is there a generalized bash function available that mimics chmod in every aspect, except that it also let's me differentiate between files and directories? I know there's already numerous examples ...
Decent Dabbler's user avatar
1 vote
1 answer
2k views

How to start fzf from another directory than the current working directory?

I often use fzf to navigate the filesystem, especially the Alt-c key binding. When invoked, fzf generates a list from the current working directory. Is it possible to make fzf generate a list from a ...
Shuzheng's user avatar
  • 633
0 votes
1 answer
318 views

move folders recursively using find

Please see the below issue. Actually I wanted to move only 20022021 folder (which cotains subdir and files) to the destination, But its moving both the directories. nasa:/# find /tmp/source -mindepth ...
nasa's user avatar
  • 3
0 votes
1 answer
141 views

(short form to) Ignore multiple filename patterns using “find”?

It seems I can ignore a certain filename pattern (*.dll) on find search by doing find ! -name '*.dll' And ignore multiple patterns by doing $ find . ! -name '*.h' ! -name '*.cpp' ! -name '*.dll' Is ...
KcFnMi's user avatar
  • 604
0 votes
1 answer
302 views

Find hidden files in non-hidden directories

Consider following directory structure: $ find m m m/f.sh m/.a I want to find hidden files in non-hidden directories with: find . -not -path "*/.*" -and -name "*.*" . ./m/f.sh ...
l00p's user avatar
  • 153
1 vote
1 answer
151 views

Understanding Operators in find command

[kony@HOSTNAME testing]$ pwd /apps/kony/fmw/testing [kony@HOSTNAME testing]$ touch SCCS [kony@HOSTNAME testing]$ touch NOT_SCCS [kony@HOSTNAME testing]$ [kony@HOSTNAME testing]$ find . -name SCCS -...
rizwan's user avatar
  • 199
0 votes
1 answer
577 views

Find number of files that contain certain String

I have a directory containing a vast amount of xml files. I would now like to find the number of files (and optionally the names of said files) that contain a certain string. XML tags do not really ...
T A's user avatar
  • 103
0 votes
1 answer
37 views

Need to find in all system files that are less than 7 days old, starts with "L" and are .txt, then generate an output file based on that

I’m working with Ubuntu and need to find in all system files that are less than 7 days old, starts with L and are .txt, then generate an output file based on that. This is what I have so far: nohup ...
Giacomo1968's user avatar
0 votes
0 answers
126 views

How to recursively rename, sort and move incoming PDF files from subdirectories

I have a program that periodically downloads certain publications in PDF format as they become available, along with additional files (e.g. *.nfo), which I don't need. The program places the incoming ...
xthursdayx's user avatar
1 vote
1 answer
309 views

Recursively search files with exclusions and inclusions

I would like to use find to recursively search files and print them to a file. I imagine a command like this: find /local/data/ --exclude 'database/session*' --include='database/session_*.db' > ...
machinery's user avatar
  • 253
0 votes
1 answer
936 views

one-liner to put two commands on same line, from the multiline output of `find... | sort... | cut ...`

This is a continuation of recursively sort files with string "SENT_" somewhere in filename by the substring immediately after SENT_, and then display them. Linux as I thought it was better ...
nate's user avatar
  • 173
1 vote
1 answer
229 views

recursively sort files with string "SENT_" somewhere in filename by the substring immediately after SENT_, and then display them. Linux

So I wish to run this from any directory, say ~/ and have it work for subdirectories. Example would be; ls ~/: /home/me/FILES/DIR_1/DIR_a/SENT_2222_.... /home/me/FILES/DIR2/SENT_3333.... /home/me/...
nate's user avatar
  • 173
2 votes
3 answers
2k views

How to chain/connect multiple -exec commands with find * and ls?

Problem I use find -exec curl in ubuntu console to list all files in directory and send them to FTP server: find * -type f -exec curl -u ***:*** --ftp-pasv --ftp-create-dirs -T {} $PATHDEST/{} \; -...
marcinpl87's user avatar
0 votes
2 answers
86 views

How to delete any archives older than W weeks, but still keep up to N archives?

I have a CentOS 7 directory that gets filled with tar.gz archives for different packages, where each package can create multiple archive versions. I'm trying to find a way to delete any archives ...
boardrider's user avatar
  • 1,153
0 votes
2 answers
143 views

Find a file with parts of name in an arbitrary order

I've got a file hidden somewhere, it's either named file.foo.bar.txt or file.bar.foo.txt, but I'm not sure which it is. Right now, I'm just running find file*foo*txt because I know the file will be ...
Brydon Gibson's user avatar
0 votes
2 answers
279 views

Symlinking with (i.e.) find | sed | xargs without xargs: argument line too long

I got stuck at symlinking using find, xargs and sed. Given folder structure: /abc /def /*/def /builds on my local machine the following statement works. find ./abc \ -type d \ -...
mowtheone's user avatar
  • 109
1 vote
2 answers
2k views

Accessing parent and grandparent directory from linux find and passing to xargs

I'm trying to do a batch imagemagick conversion on all tiffs in directories. The structure of the directories looks like: test 123 456 image.tif 256 857 ...
Goat Karma's user avatar
1 vote
1 answer
83 views

Display dirs tree based on a file content

$ find ./ | tac ./dir1/file -> "abc" ./dir1 ./dir2/file - > "abc" ./dir2 ./dir3/file -> "xyz" ./dir3/dir3_1/file - > "abc" ./dir3/dir3_1 ./dir3 or $ tree ├── dir1 │   └── file -> "...
roman-drozd-it's user avatar
4 votes
1 answer
925 views

`find` equivalent which supports .ignore files?

I frequently need to find files matching a certain name or type within a bundle of git repositories on my workstation. Some subdirectories within that bundle are only readable by root, though, so any ...
Jacob Kopczynski's user avatar
0 votes
1 answer
434 views

Perform operations on the output of find command with -exec options

I want to perform operations on the files found by the find command which already has a -exec option. find . -type f -exec zgrep -li "4168781103" {} + Output: ./results/...
Prithvi Jayaraman's user avatar
0 votes
1 answer
114 views

Removing lines from files with a specific extension

The task is as follows: From all *.h and *.cpp files, delete lines beginning with /. Removing from the current directory (or from the specified one) works well, and if there is a subdirectory in the ...
IGoogleI's user avatar
1 vote
0 answers
167 views

How to ignore FIND errors in bash script?

I'm using a script to cleanup logfiles from a tomcat webserver. Problem: find $file_pattern will return an error if a filepattern did not match any results. The following is run by crontab: ...
membersound's user avatar
4 votes
3 answers
2k views

Get the total size of all files of a given extension

I'm trying to get the total size of all the JPEGs in a particular folder, but no amount of combinations of options while piping to du seems to make this work: find -type f -iname "*.jpg" | du -sch ...
Hashim Aziz's user avatar
0 votes
4 answers
1k views

Detecting corrupted JPEGs: using find -exec with || logical operator

find . -maxdepth 1 -type f -exec identify -regard-warnings -verbose {} > /dev/null 2>&1 + || mv "$1" --backup=numbered {} -t "./Corrupted" I'm trying to use the above to check for the ...
Hashim Aziz's user avatar
0 votes
1 answer
113 views

Efficiently Fixing Ownership, Group Membership, and Mode Problems on an Extremely Large NFS Share

I am fixing ownership, group membership, and mode problems in an entire directory tree (except for two particular subdirectories) accessible to me only via NFS. This directory tree contains tens of TB ...
Dave's user avatar
  • 1,029
3 votes
1 answer
456 views

ImageMagick failing to match images lower than given dimensions

This is a follow-up question to this one. So far, I've cobbled together the following find command, which is intended to print (and once properly tested, -delete) all JPGs that are 200 x 200px or ...
Hashim Aziz's user avatar
0 votes
1 answer
1k views

Use find to delete all images under given dimensions

I just used Recuva and Photorec to recover some data off an accidentally-formatted drive. Naturally, the result is every intact file that ever existed on the drive during its lifetime. This means tens ...
Hashim Aziz's user avatar
0 votes
2 answers
728 views

Using regex groups with find

Given a list of files, I want to find all the ones ending with either .pem or .cer. This command works to find the PEMs. find . -d 1 -regex ".*\.pem" But this command finds nothing: find . -d 1 -...
Elliott B's user avatar
  • 1,235
0 votes
1 answer
201 views

In bash: How to find and delete directories containing a specific file, only if the file is older than X minutes

In bash, how can I find and delete the directories that contain a specific file, only if the file is older than X minutes. There is this answer which finds the directories that contain a specific ...
Yuval Atzmon's user avatar
0 votes
3 answers
966 views

Check if file exists

I have a folder with thousands (70G folder/to/check/) images that I, for each file want check if its already existing in another directory with thousands of thousands images (414G folder/to/search/). ...
Staplerz's user avatar
0 votes
1 answer
854 views

How to copy grepped files using Find, Grep and Exec in Git Bash

I've looked everywhere for an answer and nothing seems to be working out. In Git Bash, I need to figure out how to take files found with grep and copy them elsewhere. The instructions were to use the ...
jbingham1227's user avatar
3 votes
1 answer
1k views

Use find and do command on filename without "./" prefix

Performing a cp on filenames in multiple subdirectories and prefix them with foo- leads to an error: $ find my-dir -path "*/*" -execdir sh -c 'cp {} foo-{}' \; cannot create regular file ‘foo-./...
user2609980's user avatar

1
2 3 4 5