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

learn more… | top users | synonyms

2
votes
2answers
691 views

How to find files with a certain subpath?

I need to find all xml-files that are placed in folders named config. Also config must be somewhere under a folder named trunk. For example, I am interested in all files like below: ...
1
vote
3answers
75 views

Apply two commands to result of find

I am trying to apply two command (echo and haml --check) to result of my find. haml --check `find . -name "*.haml"` # return Syntax error on line 2: Illegal nesting: nesting within plain text is ...
0
votes
1answer
4k views

How do I redirect output from the find command (that uses grep) to a log file?

Consider the code to search for all files containing the pattern "search string": bash-3.2$ # The below find works fine.. bash-3.2$ find . -type f -exec grep -il "search string" {} \; bash-3.2$ # But ...
2
votes
2answers
851 views

Exclude all subdirectories except one specific path in a find command

I use a find command to search for all files with a given extension within the current subdirectories ignoring certain directory path: find -L . \( -wholename "*/ignoredPath" -o -wholename ...
3
votes
5answers
3k views

Find and copy directories containing file type

I have a directory "Movies" containing subdirectories "Movie Name". Each subdirectory "Movie Name" contains a movie file and related image/nfo files etc. I'm trying to copy all directories containing ...
11
votes
1answer
362 views

How to do `head` and `tail` on null-delimited input in bash?

find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
1
vote
2answers
100 views

Why don't find and locate search /bin?

What gives? Normal find and locate commands don't turn up the verify program that lives at /bin/verify. In fact, it seems they don't turn up anything that lives in /bin [jake@jace]/bin% "find" /bin/ ...
6
votes
1answer
168 views

find is missing a result — how is that possible?

What conditions explain this output: root@ip:/# find / -name "server.xml" -print /etc/tomcat7/server.xml root@ip:/# ls /var/lib/tomcat7/conf/server.xml /var/lib/tomcat7/conf/server.xml I am ...
2
votes
3answers
2k views

Passing multiple directories to the -prune option in find

I am using find to locate and delete backup files but wish to exclude certain directories from the search. The backup filenames could terminate in .bck, bak, ~, or backup. The Minimal Working Example ...
1
vote
1answer
127 views

chmod allowing write when I am not setting it

I've got a perl script which systematically changes permissions. The first thing the script does is remove all permissions. It does this by calling chmod(from perl). I did this as I found the set guid ...
3
votes
3answers
193 views

file mass deletion

I would like to delete all the txt, xls,pdf files in a directory as well as its sub directories. I would like to save everything else. find . -type f ! -iname '*.xml$,.png$,.jpeg$,.gif$,' -delete ...
1
vote
0answers
140 views

Find command incorrect results with days filter

I am trying to find all files modified before march 6 in a directory with thousands of files. I executed the following commands in the PWD where I want to find files. find -mtime +47 > ...
3
votes
4answers
3k views

How to move the files based on Year

I need to move files based on a year. I used the find command find /media/WD/backup/osool/olddata/ -mtime +470 -exec ls -lrth {} \;|sort -k6 but for this command to successfully execute i need to ...
5
votes
1answer
208 views

Execute multiple bash commands on the output of find

I want to execute some commands using the find -exec option, but I'm not sure what' wrong with this code. Currently, it's only processing the first find result, then getting stuck. I'm using bash in ...
1
vote
2answers
1k views

Delete n minutes old file in solaris

Can some one please tell me how to delete n minutes old files in Solaris? My find does not -mmin option.
1
vote
3answers
1k views

find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664; does not work

I am using this command to set permissions for files recursively clime@vm6879 /srv/www-php/steeltrading $ find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664 But after executing that command ...
5
votes
3answers
922 views

Use find result without ./

I'm trying to use find to create a bunch of symlinks but using the result with {} includes ./ before each filename. How can I avoid that? find . -type l -name '*.h' -exec ln -s /sourcedir/{} ...
1
vote
4answers
3k views

Is there a command to list files, exclude sub-directories and display size and date?

Before I begin please assume I have only basic knowledge in UNIX. Basic meaning I have only started reading about it since last week for a work related purpose. I have been experimenting with the ls ...
4
votes
2answers
1k views

remove duplicate files

On my Mac OS X 10.6.7, iTunes duplicated every single file in my music library. Now I have 3,840 files instead of 1,920. The problem is that iTunes didn't simply duplicate the whole folder, but each ...
1
vote
3answers
550 views

Why is this Bash command using regex not replacing my brackets?

I have this command to go through all my files in my Music directory, and all subdirectories, and replace any square brackets in the file name with rounded brackets: find /home/Music/ -depth -name "* ...
0
votes
3answers
588 views

How to find files ending with ~ and pyc? [duplicate]

I want to find all files (in current and all subdirectory) which end in'~' or 'pyc'. To do so I have tried the following find pattern: find . -name '*{~,pyc}' find . -name '{*~,*.pyc}' but neither ...
1
vote
1answer
701 views

What is a sure fire way to find all files and/or path that contains 2 keywords?

I was doing a find . -iname '*sitesearch*' | grep demo because I know the file should be some/path/SiteSearch/demo/SiteSearch.html, but it turned out a person put the file in as ...
6
votes
4answers
449 views

How to use find to remove *.py~ and *.pyc files at once?

I want to cleanup a directory (and subdirectories) from each occurrance of the .py and .pyc files. I tried the following find . -name '*pyc' -o -name '*py~' -exec rm -f {} \; which left out all pyc ...
31
votes
6answers
13k views

Howto find duplicate files on disk

Is it possible to find duplicate files on my disk which are bit to bit identical but have different file-names?
1
vote
1answer
174 views

Wrong behavior of xargs

I was trying to solve this issue using find + xargs but I stuck with another issue I am try to increasing a count using ((a++)) but not working . I have tried couple of combination of counting a ...
3
votes
4answers
830 views

How to count recursively for the number of files in several directories?

I have a directory, containing a lot of files and directories. I am trying to get the number of files (and directories) contained recursively in every directory. I tried the following approach: for ...
0
votes
3answers
2k views

Find executable files recursively

I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command. ls -l `find ...
0
votes
1answer
259 views

Copy modified files from one server to other

Scenario: 2 Servers (*.12 and *.13) CakePHP "application" on both of them. *.12 is "Production" Server *.13 is "Development" Server Now i want to copy all files modified the last 2 days from test ...
1
vote
2answers
1k views

Find all directories, in which user has access to search and echo this directories in shell

I need to find all directories, in which user has access to search(command find) and echo this directories in shell. USER is read from ksh. for example: read user I know, if user want to use find ...
6
votes
5answers
2k views

Script to remove spaces and lowercase in file names

I am trying to write a script that will replace spaces with "-" and make all letters lower case for all files in the current directory. for x in 'ls' do if [ ! -f $x ]; then ...
3
votes
2answers
498 views

How to run "find -exec <script> {}\;

I have a script that changes the properties of the files for a folder. Here is the example tree: dir 1 --file 1 --file 2 --file 3 dir 2 --file 1 --file 2 dir 3 --file 1 ...
1
vote
3answers
577 views

What does a question mark in a filename matching pattern mean?

What does the question mark in this command mean? find . –type d –name "?d*" –print I tried to to run it without it but didn't notice any change.
2
votes
1answer
90 views

Why is the output of find sorted in Cygwin but not in Solaris?

I wonder why find does not behave in the same way in Solaris as in Cygwin or Linux. I have a bunch of directories that have files called CS##########. Each # is a digits but there are always 10 ...
2
votes
1answer
121 views

Can this find command be made more compact?

Please look at these two commands: find ~/{Documents,Desktop,Downloads,Music,Videos} -mmin -120 -type f and find . ! -path "*opera*" ! -path "*mozilla*" ! -path "*google-chrome*" -mmin -120 -type f ...
3
votes
3answers
2k views

How to Calculate the Total size of file searched using Find command

Actually there are tow questions. First I have to search the files using FIND command that will show only the files for December 2012 And Secondly I need to see the Total size of files searched I ...
3
votes
4answers
153 views

removing folders with find - strange message

mkdir foodir find . -iname foodir -exec rm -fr {} \; It does the job, but barfs message: find: `./foodir': No such file or directory
1
vote
4answers
2k views

rsync timed out

I need to sync a directory to a directory on a remote server. at the moment i use rsync -ca to do this but the directory is quite large and the whole process fails with a timeout error. Now i'm ...
1
vote
1answer
338 views

Quoting curly braces in the shell [duplicate]

I found examples of different quoting for curly braces for find, but I could not find an explanation. The possible choices are: 1. {} 2. '{}' 3. "{}" And they all seem to work fine. Is ...
2
votes
3answers
886 views

Find directories that do not contain subdirectories

I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories. I know that I could use ls -alR and recursively parse ...
10
votes
1answer
1k 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 ...
0
votes
1answer
164 views

find in /sys/class does not show everything, why?

Like every other person I am from time to time compelled to list the directory structure from a certain point int the filesystem. I do so with find /path/in/fs/ and this yields something like: ...
1
vote
2answers
338 views

A bunch of files have 777 permissions

I have been learning Python and Bash scripting, and I up to now I have given my scripts 777 permissions. Having learned more about how to set permissions, and knowing this is a bad idea, I ran the ...
0
votes
1answer
722 views

Rename files and directories with a special characters on solaris machines

The target of the following code ( commands ) is to rename files/directories and also support files/directories with a special characters as "@" or "." etc those commands are run fine on Linux ...
4
votes
4answers
8k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
5
votes
1answer
2k views

Exclude directory in find

How can I find every file and directory matching a pattern, excluding one directory using find? Say I have the following file structure; . foo-exclude-me/ foo.txt foo-exclude-me-not/ ...
2
votes
2answers
382 views

Use a parameter in a command argument

I run a find command to search files with a name containing perl: find /tmp -name '*perl*' /tmp/perl.pl /tmp/run-perl-stage.pl But when I set the perl name in a variable PARAMETER and run the find ...
2
votes
3answers
1k views

`solaris + xargs command for solaris

the command find /tmp -name 'core*' -type f -print0 | xargs -0 works fine on Linux, but xargs -0 option is not legal on Solaris what is the equivalent option ( xargs? ) for Solaris 10 second ...
4
votes
2answers
3k views

find command with regex {1,2}

I have been trying to create a find command string that will find all files that end with a number 1-99 but exclude all others. e.g. I want to find myfile1 myfile99 but not myfile456 and not ...
1
vote
1answer
612 views

How to check Today's Day and Search Files

Problem: I need to find out today's date and search a file which contain's today's date in the name. Also another file which contains Yesterday's date. I was able to do so by something like: ...
2
votes
2answers
192 views

Select greatest numbered filename

Simple requirement but can't find anything online which can achieve it. I have a list of dated files as below... filename_20120101.dat filename_20120102.dat filename_20120103.dat I ...