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

learn more… | top users | synonyms

2
votes
1answer
64 views

Check for related file names and delete one of them

I need to write a script that will find files that contain a string in their name. If a file exists that is the same name but without that string, I want to remove the original file. For example, if ...
-2
votes
1answer
52 views

Find part of filename

Please help with my task: I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names. I need to create a shell script ...
1
vote
2answers
50 views

xargs repl_str doesn't expand second placeholder

I would like to rename some files and exclude others into a directory. I tried find . -mindepth 1 -maxdepth 1 ! -name 000-default.conf ! -name default-ssl.conf -print0 | xargs -0 -I {} sudo mv -- {} ...
0
votes
1answer
71 views

Find command to check only for the last 10 minutes and not the whole folder

I have an nvr system that recording video surveillance into a file server (Debian). I made a Nagios plugin to check if the NVR system is recording correctly and send me a notification when it stops ...
1
vote
1answer
18 views

copying sub-directories not containing a specific file into another directory

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I get the list of sub-directories that does not contain a file stdout based on solution given ...
0
votes
1answer
26 views

Find filename using list inside a file

How can i find all filenames that match a string in a list inside a file? I have a list_file.txt with a list of email addresses each in a new line like this: 1@mail.com 2@mail.com 3@mail.com ... ...
0
votes
0answers
69 views

Directory research example

I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names. I need to create a shell script that checks all the folders ...
-2
votes
1answer
65 views

What is the difference when using FIND between -name and -iname

Well the question says it all, I have seen both find -name and find -iname used all over the place without a discernible pattern. Could somebody explain the differences, perhaps with an ...
2
votes
2answers
30 views

Pipe Find Results for '*.squashfs' to unsquashfs

I am looking for something that will find the squashed filesystem, and the pass the output to unsquash the fs and it would have to be an absolute path outside the squashfs. example ...
2
votes
2answers
43 views

Copy file and file structure and merge in new directory

I used the following command line find src -name '*.json' | cpio -pdm lib So it found the json file as in the sceenshot below But then it takes the whole directory structure and places it into ...
0
votes
1answer
41 views

Folder research task

I have a folder with 3 subfolders containing 6 files each.There are 2 files in each subfolders with :NOPM in their file names. I need to create a shell script that checks all the folders and their ...
1
vote
2answers
77 views

Issue when I try passing parameters to find command?

Parameter: export exc_lst='! -path "/var/app/s2/pnl/incoming/recondata/*.*"'; When I try using the below find commands: find $FILE_DIR -name "*.*" "${exc_lst}" -type f -mtime +20 -user sh79790 ...
13
votes
9answers
16k views

How to chain the commands 'date -d @xxxxxx' and 'find ./'?

I have directories whose names are timestamps, given in milliseconds since 1970-01-01: 1439715011728 1439793321429 1439879712214 . . And I need an output like: 1442039711 Sat Sep 12 08:35:11 ...
0
votes
2answers
109 views

How to find all files matching (or not matching) a specific pattern in a folder?

How do I find all files in a folder and its subfolders terminated with 3 digits and move them to a new place while keeping the directory structure? Alternatively, how can I find all files whose ...
2
votes
3answers
55 views

find and md5sum not yielding any output (find -o limit?)

I ran into a situation that I don't really understand. I have a bunch of backup files in a recursive structure of which I want to calculate the md5. When I add some additional file extensions the ...
0
votes
1answer
12 views

Obtain filepath of directories containing a particular filetype in alphabetical/numerical order [duplicate]

I have a directory that contains 800 subdirectories named disp-001 ... disp-800. All these sub-directories need to contain a specific file say stdout. One among them does not contain the file and I ...
1
vote
2answers
127 views

Why is find not accepting '-exec cp {} dir +'?

I have a directory, dir1 which contains many files whose names end in either .jpg or .png. I want to copy all the .png files to dir2 which is empty. This command works: find dir1 -name '*.png' -exec ...
0
votes
2answers
45 views

Bash script to copy specific directories with pattern matching

How can I copy directories from one location to another location that matches a pattern. For example: source = /media/src/ destination = /media/dest/ The pattern is as /b/w{2}_/w{2}/b. i.e all ...
0
votes
2answers
254 views

simple command “find” not working

so I'm in the main folder for my web hosts, trying to find a file using find. I couldn't find it - it was listed as no such file or directory - and I thought maybe it isn't anywhere. However the ...
1
vote
2answers
616 views

How to rename multiple files using find

I want to rename multiple files (file1 ... filen to file1_renamed ... filen_renamed) using command find command: find . -type f -name 'file*' -exec mv filename='{}' $(basename $filename)_renamed ';' ...
0
votes
2answers
100 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 ...
7
votes
3answers
1k 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 {} \;
3
votes
3answers
212 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
40 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 ...
1
vote
2answers
84 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 ...
4
votes
5answers
465 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 ...
3
votes
1answer
282 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 ...
0
votes
1answer
222 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: ...
1
vote
2answers
76 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
1answer
71 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 ...
2
votes
2answers
60 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
4answers
51 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 ...
4
votes
3answers
48 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 ...
0
votes
3answers
82 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 ...
2
votes
1answer
68 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
2answers
320 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 ...
4
votes
3answers
107 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
2k 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
74 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 ...
1
vote
1answer
38 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 ...
0
votes
1answer
60 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 ...
1
vote
1answer
30 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 whose home directories sizes are greater than 10G and send a notification to them. I ...
2
votes
1answer
115 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
1answer
85 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 something ...
3
votes
3answers
428 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
2answers
68 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 / ...
1
vote
1answer
40 views

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

I'm generating ctags using something like the following line find -iname '*.[hc]' -exec ctags -a --sort=no {} + The result is that tags are not sorted. For that I'm using sort -u -o tags tags ...
3
votes
2answers
98 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
76 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 ...
2
votes
1answer
148 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 ...