find is a command line utility to search for files in a directory hierarchy

learn more… | top users | synonyms

6
votes
3answers
850 views

Can someone explain what this command does?

Can someone explain to me what this command does? EDIT: Do not run this command! It will break your installation. sudo find / -exec rm {} \;
0
votes
2answers
59 views

Why does this command not remove files as expected?

This command in my .sh script is supposed to look in /home/backup/VBtest for .sql.gz files and remove any older than 5 days: find /home/backup/VBtest/*.sql.gz -mtime +5 -exec rm {} \; But it ...
3
votes
3answers
33 views

With find -exec grep, how to print only basename or split filename/line content on separate lines?

I'm looking at source files. For PureBasic actually, but whatever the language, there are common elements involved. In my case, the command would be cover extensions pb, pbi, pbf, and pbp: find . ...
0
votes
3answers
32 views

Backing up files [duplicate]

I would like to backup all files older than 90 days and greater plus gzip them. I could execute: find /path/to/files -type f -mtime 90 -exec gzip "{}" \; Problem with this command is it includes ...
4
votes
5answers
185 views

delete folders older than 1 day

I want to delete all the folders that are older than 1 day with following command: find /test -mmin +1440 | xargs rm -rf But the output of find lists /test (and would remove it accordingly). How ...
1
vote
2answers
48 views

Optimize/Replace 'find' command

I am looking to optimize this find command. We have to move a bunch (sometimes almost a million) files to a directory for further processing. We are looking for a way to increase the speed of this ...
2
votes
2answers
55 views

How can I turn `file` tool into a predicate for `find`?

I have something like: find . -type f -print0 | xargs -0 file | grep Matroska | cut -d: -f 1-1 | xargs rm I want something like: find . -type -f -filemagic "Matroska" -delete
0
votes
1answer
32 views

find delete shows “No such file or directory”

I just run a command to "find and delete files & folder older than 100 days" on a folder, and got the following: $ find . * -mtime +100 -delete find: May_01_2015: No such file or directory find: ...
3
votes
1answer
154 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
-2
votes
3answers
467 views

find command and tar

find /informatica/dev/SrcFiles* -mtime +7 -and -size +1M -exec tar -cvjf> So I ran this command and I can't find the file after it was done running (probably because I never named it?). The ...
4
votes
3answers
573 views

Find files in directory with paired names

I'm running tests of a variable-size-and-contents test set. Data files are added and removed frequently. I'm looking for an automated way of gathering a file list. All files are in subdirectories of ...
1
vote
2answers
47 views

find path directory in sub directory

I want to find the path for directory name bbb where the parent directory called aaa For example /aaa/bbb /tmp/aaa/bbb /usr/bin/aaa/bbb /home/aaa/bbb /home/aaa/xxx/bbb So i wrote something like ...
3
votes
3answers
915 views

Which is a better way to search- find with regex or find with grep?

Of these two ways of searching a file recursively in all the subdirectories, which is faster / better ? find . -regex ".*/.*abc.*" or find . | grep ".*abc.*"
3
votes
1answer
27 views

Executing awk on each file found with find, then redirecting the result to a new filename

I am trying to take the results from find and then execute awk to print the first two columns. Then I want to redirect those results to a new file name for each file, using the existing file name with ...
12
votes
4answers
47k views

How can I list subdirectories recursively?

The obvious ls -dR does not work. I am currently using find /path/ -type d -ls but the output is not what I need (plain listing of sub-folders) Is there a way out?
4
votes
2answers
277 views

How can I find files with permissions greater than xxx but ignore files with SUID and SGID

I'm trying to find files with permissions that exceed 755. Using the solution from another post here I have been able to get mostly what I want: find /bin -type f -perm -755 ! -perm 755 This does ...
5
votes
5answers
7k views

find command in cygwin giving parameter format not correct

I am using cygwin in my windows machine. I am trying to do a find and it is giving parameter format not correct. Why is that? $ ls bootstrap.jar catalina-tasks.xml catalina.bat catalina.sh ...
0
votes
4answers
39 views

Clearing the content of files by size

Considering if I list files in a directory: drwx--x--x 43 root wheel 4.0K Aug 18 12:52 .. -rw------- 1 root root 268K Aug 18 04:31 build_locale_databases_log -rw------- 1 root root 5.2M Aug 18 ...
0
votes
3answers
62 views

find command behaviour inside for loop

I have following part of code inside bash script. for dir in $(find /etc/aaa -type d -maxdepth 1) do #my code done #my code if /etc/aaa directory is not present then i want to exit script with ...
4
votes
3answers
28 views

How to search with GNU find for several file types at a time?

How is it possible to use the GNU find command to match several file types at a time (one search command)? The man page says: -type c File is of type c: b block (buffered) special c ...
8
votes
6answers
32k views

How to search for a word in entire content of a directory in linux

need to search for something in entire content I am trying: find . | xargs grep word I get error: xargs: unterminated quote How to achieve this?
2
votes
1answer
31 views

Find | parallel executing script with path from find + other arguments

Due to my lack of Bash knowledge I've tried for a few hours now to get something like this to work: find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {Found Directory} {1} ...
4
votes
3answers
71 views

How to remove space in all sub directories in shell script?

I tried following shell script to remove all spaces with underscores: find $1 -depth -name "* *" -print0 | \ while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done If I have a directory ...
7
votes
2answers
555 views

How to replace spaces in all file names with underscore in Linux using shell script?

I tried following shell script which should replace spaces from all xml files for xml_file in $(find $1 -name "* .xml" -type f); do echo "removing spaces from XML file:" $xml_file mv "$xml_file" ...
5
votes
1answer
47 views

Exclude directory in (native Solaris) find command

I'm trying to exclude the directory /zones in my find command. I don't have GNU find available, just the native Solaris find. I tried something like this: find / -type d ! -name zones The problem ...
4
votes
2answers
12k views

How to find and delete files older than specific days in unix?

I have got one folder for log with 7 folders in it. Those seven folders too have subfolders in them and those subfolders have subfolders too. I want to delete all the files older than 15 days in all ...
12
votes
7answers
14k views

How to report number of files in all subdirectories?

I need to inspect all sub-directories and report how many files (without further recursion) they contain: directoryName1 numberOfFiles directoryName2 numberOfFiles
1
vote
1answer
12 views

copy files with md5-based target name using find and xargs

I have a directory tree with many .dat files, where many of them contain special characters. They are used by another process which is only able to process files containing ascii characters. My idea ...
1
vote
1answer
67 views

POSIX-compliant recursive grep with no errors for inaccessible directories

What script would allow me to grep a keyword and print the filename containing the keyword inside the file content , for example 'Carhart' inside all .sas files in all subdirectories, I tried ...
0
votes
1answer
24 views

How to pull one day old data from remote server to local server?

From what I have searched till now I only found command to PUSH one day old data from local server to remoteServer but what I want is to PULL one day old data from remoteServer to localServer. I ...
23
votes
5answers
24k views

Sorting the output of “find”?

I need to be able to alphabetically sort the output of find before piping it to a command. Entering | sort | between didn't work, so what could I do? find folder1 folder2 -name "*.txt" -print0 | ...
1
vote
1answer
22 views

List folders greater than 10G and mail to respective owners about the usage

In our environment, we have an NFS mount which contains all users home directories. I want to find the users who's home directories sizes are greater than 10G and need to send a notification to them. ...
2
votes
3answers
202 views

How can I exclude all “permission denied” messages from “find” in Solaris

Hi previous questions on this topic contain answers for Linux but does not work for Solaris 10. find . ! -readable -prune Does not work in solaris since -readable is not POSIX. What is the POSIX ...
2
votes
1answer
33 views

Cp files into subdirectory with find -exec

Why is this command not copying the 17 .png files into a sub-directory within my current directory? $ find . -maxdepth 1 -mtime -3 | wc -l 17 $ find . -maxdepth 1 -mtime -3 -print0 | grep -z loader ...
1
vote
2answers
26 views

How can I list files by class/indicator (as in ls --classify) then by name?

ls --clasify append indicator (one of */=>@|) to entries. I would like to group the entries of the same class/indicator together. I can only find ls --group-directories-first for grouping the / ...
97
votes
8answers
42k views

How can I find broken symlinks

Is there a way to find all symbolic links that don't point anywere? find ./ -type l will give me all symbolic links, but makes no distinction between links that go somewhere and links that don't. ...
2
votes
5answers
2k views

Use mogrify to resize large files while ignoring small ones

I'm running the following command: mogrify -resize '400x400>' *.png Notice the ">". Supposedly it will ignore smaller files, but although it doesn't resize them, it edits them (modification date ...
5
votes
3answers
15k views

List of Recently Modified Files

How can I Get a list of all files modified , say 3 months ago. I checked this question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there ...
8
votes
2answers
3k views

Deleting files by age

Is there a command to delete all the files in a directory that haven't been modified in N days? I need to clean up some old logs.
10
votes
2answers
18k views

Why is my find not recursive?

I am running the following command, but it is not performed recursively: find . -name *.java I know there are java files further down in the current directory but it is performing the find on the ...
1
vote
1answer
29 views

Add arguments to last invocation of `find … -exec $COMMAND {} +`

I'm generation ctags using something like following line find -iname '*.[hc]' -exec ctags -a --sort=no {} + Consequence is, that tags are not sorted. For that I'm using sort -u -o tags tags What ...
2
votes
2answers
3k views

Get list of all files by mask in terminal

I want to find all *.h,*.cpp files in folders with defined mask, like */trunk/src*. So, I can find separately *.h and *.cpp files: find . -path "*/trunk/src/*.h" find . -path "*/trunk/src/*.cpp" ...
3
votes
2answers
81 views

How to alias part of expression for find?

I prefer regular expressions with -regex over the shell pattern syntax of -name. I also want to use the posix-egrep type, so I'd like to do something like alias find="find -regextype posix-egrep" ...
0
votes
2answers
30 views

How could I run -exec on find command after | grep

I am on a remote machine attempting to move all loader.gif files into a /Pictures folder find . -iname *.gif | grep loader shows four file I would like to move, naturally I tried: find . -iname *.gif ...
10
votes
4answers
22k views

Getting all files that have been modified on a specific date

Is it possible to find all php files within a certain directory that have been modified on a certain date I'm using find /var/www/html/dir/ -mtime -28 | grep '\.php' to get files modified within ...
12
votes
1answer
3k views

Only find first few matched files using find?

Say there may be hundreds of *.txt files in a directory. I only want to find the first three *.txt files and then exit the searching process. How to achieve this using the find utility? I had a quick ...
2
votes
1answer
59 views

How to use regex inside exec with find?

Is it possible to use regular expressions based on the result (file name) inside the exec argument with find? I want to be able to "exec" based on parts of the argument, like: find . -name pattern ...
4
votes
2answers
594 views

Passing parsed output of sed to find (in this direction)

Well, I think you can find dozens of questions on this platform how to pipe find output to sed, but I haven't found anything for the reverse direction so far. What I want to do is modify my input, and ...
4
votes
1answer
73 views

How do I find a file name that's exactly 8 levels deep?

I'm using the 'find' command to search for files in a backup system. I want to find all file names containing a certain string (e.g. 'XYZ') that are exactly 8 levels deep. Is there a find syntax that ...
0
votes
5answers
95 views

List only the count of all files/directories for the directory tree of present directory

I want to list the number of directories under each subdirectory tree of the present directory. As there are too many directories, I can't go into individual directory and check. Something like the ...