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

learn more… | top users | synonyms

1
vote
2answers
24 views

Getting the size of parent folders when using find to search for criteria?

I am hunting for a certain regular expression within the filenames and am seeking to return the parent folders with their sizes in a unique fashion. For example, here is the command that I expected ...
1
vote
3answers
43 views

shell script for auto-touching files

I have written a shell script to touch all the files in the /tmp directory. However, there was an error message saying that /bin/touch: Argument list too long. What's the cause of the problem? ...
4
votes
2answers
35 views

Find all symlinks to a directory and change target to another directory

I have a bunch of symlinks in /home to files and sub-directories in /foo. I want to target the new directory, /bar. My approach was to look at all invalid symlinks and verify that they were pointing ...
1
vote
1answer
26 views

sliding window of JPGs from thousands of files

My machine has a camera attached that can take thousands of jpgs a day. I am looking for a way of remotely looking at the last 30 to 60 mins of footage via a cloud storage site such as box.com. I ...
4
votes
2answers
76 views

Why does 'find -delete ' delete all files in a directory recursively

So the following behaviour of unix find just cost me dearly: > touch foo > touch bar > ls bar foo > find . -name '*oo' -delete > ls bar > touch baz > ls bar baz > find . ...
2
votes
1answer
35 views

rolling snapshot of pictures taken in the last half hour

I've taken this: find -maxdepth 1 -mtime +1 -type f -exec cp '{}' backup \; Which should copy all the regular files in the current directory more than 1 day old to the directory backup (assuming ...
-4
votes
1answer
72 views

What command in bash to search for this string?

file.txt contains: aa=testing sss=whoiam bbb=findme What command do I use to search for testing and print it? Expected result: # you search testing
2
votes
1answer
28 views

How do I search files without certain extensions in their names?

I would like to search recursively in all the files and directories under a directory for some strings e.g. library. I also would like to exclude files and directories which store downloaded ...
2
votes
4answers
146 views

Execute all files in a list

I have a source tree which, when make is run, produces several executables named "001", "002", and etc. I'm trying to write a script which will find all of these executables in my source tree, and ...
1
vote
1answer
17 views

How to delete older files in a folder in unix?

Can anyone help me find the meaning of the below statement? I am new to Unix programming. find /sourcedirectory -mtime +2 -exec mv "{}" /destination/directory/ \;
0
votes
1answer
28 views

ls command - list files containg speccific string in file name and belong to specific type

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will ...
0
votes
4answers
35 views

Find a directory created today

How can I find a directory whose name starts with cy and that was created today?
3
votes
2answers
72 views

Why does find -exec du sum up differently?

I have family pictures and movies in a folder /media/data/Selbstgemacht and I'd like to find the size of all pictures. In /media/data I use find Selbstgemacht -type f -iname '*.jpg' -exec du -ch '{}' ...
-4
votes
1answer
38 views

What is the significance of the the leading “4” before the listing of modified files?

After running the following command: find /Users/UserName/Documents -type f -mtime -1 -print0 | xargs -0 du -sk | sort -nr I receive the following output: 4 ...
0
votes
2answers
32 views

Skipping pseudo-directories with find /

There are some directories that can cause problem with find, and especially "find /". These are directories in which the OS creates files which are not really files. Among these directories are /proc ...
3
votes
5answers
73 views

How to find and empty some directories

I'd like to find and delete the contents while leaving the directories themselves intact. The following find /data1 -name MyTargetDir -type d -exec rm -rv {} \; and find /data1 -name ...
6
votes
4answers
117 views

Find newest file. Multiple Filetype restrictions

I want to write a command that gives me the newest file in a directory recursively. But that's not my only limitation. The files has to be an mp3 or a jpg file. (case insensitive prefered) I only need ...
5
votes
2answers
68 views

Where does the pattern occur in a match by find?

The manpage of find says: -name Base of file name (the path with the leading directories removed) $ find ~ -name bookmark | less returns nothing, while $ find ~ ...
1
vote
4answers
64 views

Finding a file which created X minutes back (without GNU/BSD find)

I am using the find command to find the files which were created with in 30 minutes. find . -ctime -30m But it is giving files from up to 30 days. I have tried -mmin too but it is showing that ...
1
vote
2answers
51 views

How to determine the newly closed file within a continuous audit log rotation?

I am attempting to find the best way to determine when the second file (of a matching criteria) is created. The context is an audit log rotation. Given a directory where audit logs are created every ...
1
vote
1answer
38 views

How to specify file path with find when searching for files with -regex

I want to search a directory for some files using find and a regular expression. If I do cd dir find -E . -type f -regex '^\..*[^~]' I get a list of files in the directory that match the the ...
4
votes
3answers
101 views

Find a file which is 30 minutes old

How can I find the file which is of 30 minutes old in /bin/ksh?
4
votes
1answer
130 views

Find directories and files with permissions other than 775 / 664

I am moving a website from one server to another and Git does not store metadata such as file permissions. I need to find the directories and files that are not 775 / 664 respectively. Right now, I'm ...
3
votes
1answer
81 views

find files without extension

Let say I have: foo.txt bar baz.ooo If I use ls -1 !(*.*) then I'll get only bar on the output. Great, now I wish to have same results with find - some find -regex that will do the job. NOTE: ...
0
votes
3answers
38 views

cd to the most recently created directory [duplicate]

I have a directory in which a number of directories are created daily. I want to enter into the directory which is created recently whose name starts with cy. How can I find this directory? Could ...
3
votes
3answers
63 views

Moving latest files from one directory to another

I'm trying to move newest files from one directory to another directory. The find command finds the files but not moving them to another directory. The destination directory exists. $ cd ...
0
votes
3answers
63 views

find command: -or option doesn't work

I want to execute a command for an each file that matches a pattern. But the command that seems to be right, doesn't work for me, I have no idea why. $ find . -type f -name '*.c' -or -name '*.h' -or ...
0
votes
1answer
28 views

How do I use find to individually zip files in a directory?

I was expecting something like, find . -name "*.bor" -exec sh -c 'zip ???' sh {} + where the ??? are replaced with $@ or similar. The end result needs to look like, 1.bor.zip 2.bor.zip etc.
0
votes
2answers
71 views

Get only file name from find command and mail

The following find command will results multiple files and send mail all those find /home/cde -ctime -1 -name "Sum*pdf*" -exec uuencode {} {} \; |mailx -s "subject" abc@gmail.com But I am getting ...
2
votes
3answers
317 views

Is this command safe to run from / as root

find . * -depth -print0 | xargs -0 rmdir It finds and removes all empty folders (including hidden ones) recursively. I only tired it on my home folder and a pendrive in Linux PC and it worked but I ...
2
votes
3answers
37 views

Attachments are missing when multiple files are attached in mail

I have written one script to get multiple attachments through mail. My script is for file in `find $dir -ctime -2 -type f -name "Sum*pdf*"` do echo "$file" filename=`basename $file` echo $filename ...
1
vote
1answer
43 views

How to get find -exec to call a shell script?

Taking from the last answer (by im3r3k) here: How do I recursively shred an entire directory tree? I'm trying to get the find command to call a shell script as described. So far I've tried: find ...
3
votes
1answer
73 views

How to ignore -ls errors in find

I'm writing a find command to look for files or folders with broken permissions (files should be rw, directories rwx) and trying to ls -l (give or take) the results. The following find command looks ...
2
votes
4answers
107 views

Sort the output of find -exec ls

Is it possible to the output of find … -exec ls -ls ; sorted alpabetically, by filename? This is my cron command: find /home/setefgge/public_html -type f -ctime -1 -exec ls -ls {} \; This command ...
2
votes
2answers
56 views

Remove files and directories even if not empty, except some directories

I am trying to remove all contents of a directory with some exclusions. I'm currently using this: find . -type f | grep -vZf ../../exclude.file | xargs rm -rf The exclude.file contains: *log* ...
3
votes
2answers
87 views

Finding all large files in the root filesystem

I have a linux server, which currently has below space usage: /dev/sda3 20G 15G 4.2G 78% / /dev/sda6 68G 42G 23G 65% /u01 /dev/sda2 30G 7.4G 21G ...
0
votes
0answers
38 views

Storage Formats for Flat File DB

Currently I use a flat file database with find -type f -ls to store information for about 400GB of files. I'd like to store also the md5sum/sha[1|256]sum of the files. Because the files are often ...
1
vote
2answers
62 views

Using exec in find over ssh from shell script

So, I am attempting to execute the following from within a shell script; ssh -q $CUR_HOST "cd $LOGS_DIR; echo cd $LOGS_DIR; find . -name *.log -mmin +1440 -exec gzip {} \; exit" When this runs, it ...
2
votes
2answers
41 views

can regex capture groups be used in GNU find command?

With the GNU find command (GNU findutils 4.4.2), a regular expression can be used to search for files. For example: $ find pool -regextype posix-extended -regex ...
2
votes
1answer
32 views

find -exec doesn't do what find output suggests [duplicate]

If I do this find: find ${TRIADS_DIR}/*.dc.results -path "*amblock/stats.*HEAD" -o -path "*amblock/stats.*BRIK" then I get what I expect in STDOUT: ...
0
votes
0answers
62 views

Find if the file is compressed or not

I need to find whether the file is compressed or not in script.If it is compressed I need to uncompress and send as attachement. My find command results in two files sum12.pdf.Z and sum23.pdf.Z My ...
0
votes
2answers
38 views

Output multiple strings out of multiple files

Hi my current code is: find /home/user/logfilesError/ -maxdepth 1 -type f -name "gBatch_*"\ -daystart -mtime -1 -exec grep -rl "ERROR" "{}" + | xargs -l basename if [ $? -eq 0 ]; then ...
1
vote
1answer
69 views

Extract file name from find command

I am trying to extract the file name and attaching to mail. But when I send mail the attachment is coming with path name and file name. Ex: dir=/home/as123/bill and filename=abc.pdf.Z and I am ...
2
votes
1answer
46 views

Why can't I chmod these files that I could earlier?

I was trying to add execute permissions to sh files in a folder. For that I mistakenly used: find . -print0 -iname '*.sh' | xargs -0 chmod -v 744 and the output was : mode of `.' changed from 0755 ...
5
votes
1answer
45 views

Can “find” command preserve access-time

I'm running the following command which is supposed to find specific directories according to their Access-Time metadata detail however for some reason the find command changes the access time of ...
0
votes
1answer
33 views

Why do these 2 find commands give differnt results?

I wanted to see all files modified within the last 10 days and who owned them, so i entered the following to give me an idea how many results would be returned; find . -maxdepth 1 -mtime -10 I then ...
6
votes
2answers
203 views

fastest way to grep jar file for a particular name in it?

I am trying to find all the jars which has spring in its name. I am working with windows and using cygwin to run the linux commands. Does my below command looks right? find . -name "*.jar" -exec jar ...
3
votes
2answers
108 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 ...
4
votes
3answers
114 views

zsh's “echo SomeText >> **/filename” in other shells

I need to fill all files with a specific filename (recursively) with a text. In zsh this can be done with echo SomeText > **/TheFileName I search generic solutions for sh-compatible and/or tcsh ...
5
votes
6answers
236 views

Use find to find certain directory and delete all files in it except one directory

I'm having the following problem. I have a directory structure and want to delete everything that is within a directory named Caches. Everything should be delete except all directories named ...