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

learn more… | top users | synonyms

1
vote
4answers
126 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
78 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
83 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
475 views

Find a file which is 30 minutes old

How can I find the file which is of 30 minutes old in /bin/ksh?
5
votes
1answer
626 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 ...
4
votes
1answer
1k 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
70 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
1k 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
187 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
34 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
202 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
331 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
134 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
104 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
85 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 ...
3
votes
4answers
1k 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
207 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* ...
8
votes
2answers
3k 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
54 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
439 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
72 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
34 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
126 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
40 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
128 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
206 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
62 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
49 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
658 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
159 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
132 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
411 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 ...
7
votes
6answers
1k views

“find: .: No such file or directory” while using find on the current directory

Find command seems not to work at all. For example, I'm in a directory where there absolutely is file named index.php and I execute this: [root@server htdocs]# find . -name "index.php" find: .: No ...
2
votes
4answers
175 views

Generate multiple symbolic links with maitaining directory structure

I want to generate symbolic links from multiple folders with maintaining the directory structure. I read a few answers and the best thing i can come up with now is: find ...
1
vote
0answers
29 views

-exec isn't being passed all the files found by find [duplicate]

There are two files called install.log and install.sh The find command will find both of these and pass them to -exec ls With the addition of an or (-o), it only passes one argument to -exec ls ...
0
votes
1answer
63 views

How to output the lines of a file after find and a grep?

Hello I want to output ERROR messages from logfiles from the current date. First I search for the logs of today with specific prefix: find /home/USER/logfilesError/ -maxdepth 1 -type f -name "xy_*" ...
0
votes
2answers
42 views

How can I search filenames which are starting with xy_* and are created/edited today?

Hello I´m currently trying to search for logfiles which are starting with xy_Number and are created/edited today(not last 24 hrs). I tried: find /home/USER/logfilesError/ -maxdepth 1 -type f ...
7
votes
2answers
149 views

break out of find if an -exec fails

Is there a way to write an find so that it breaks if one of the -exec operations fails on a file? E.g. (javac is conveniently used as a program that can return an exit code of 1 on some files and for ...
2
votes
4answers
230 views

Copy files and directory tree for filesize in specified range

Hi I would like to make a small script copying files from different directories example /pp/01 /pp/02/ etc... to another destination with the same directory design. But only those files within the ...
1
vote
2answers
51 views

How to locate a file in a directory

How can I locate a file using locate in CentOS under a specific directory from terminal? Locate search the whole database!
8
votes
5answers
718 views

How to search for files with immutable attribute set?

For config auditing reasons, I want to be able to search my ext3 filesystem for files which have the immutable attribute set (via chattr +i). I can't find any options for find or similar that do ...
0
votes
1answer
36 views

better use of find - rvm.sh

I am trying to find rvm.sh as I am receiving the infamous rvm is not a function error. The file in most linuxes is supposed to be at /etc/profile.d/rvm.sh However on opensuse it is not there so I ...
4
votes
1answer
196 views

Blank lines when executing “grep | xargs” in a “find -exec”

I'm trying to list all directories of a web server that are blocked by Apache via a .htaccess (containing deny from all). I've managed to get the list of blocking .htaccess but when I try to extract ...
3
votes
3answers
1k views

'is a directory' error when trying to pass directory name into function

Note: I am a newbie to bash scripting In my bash script, I use find to get the folder names by wildcard: for i in $(find ${directory} -mindepth 1 -type d -name ${wildcard}); do stuff=doStuff ${i} ...
6
votes
3answers
5k views

Recursive grep vs find / -type f -exec grep {} \; Which is more efficient/faster?

Which is more efficient for finding which files in an entire filesystem contain a string: recursive grep or find with grep in an exec statement? I assume find would be more efficient because you can ...
2
votes
0answers
439 views

diff -r only for certain file types

Is there a way I can perform a recursive diff of two directories but only compare (in their respective places) files that match a specific filename or filetype predicate? E.g. I would like to do ...
1
vote
2answers
31 views

Deleting user directories with . in name

I have directories with usernames as "firstname.lastname" and firstname.middle.lastname in one directory. Is there a way to delete directories with "." in name under current directory. I need to run ...
1
vote
1answer
63 views

Using a zsh function in find?

I'm on OS X and have defined a function called finderpackage that tries to determine if a folder is in fact a "package" (also, somewhat erroneously, known as a "bundle") according to the Finder. My ...
1
vote
0answers
62 views

Why below script is not able to find and delete files [closed]

Why below find command does not find and delete files ? I am launching it like this ./script.sh 1 MYFOLDER days_period=$1 myuser=$(whoami) folder_prefix=$2 LOGS_DIR=~/$folder_prefix/logs if [ $# ...
3
votes
2answers
1k views

find the single largest file

We host a share of size 4 TB. How efficient is it to find a file with highest size. Usually we use: du -ak | sort -k1 -bn | tail -1 and it is not easy to scan through a share of such huge size and ...