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

learn more… | top users | synonyms

2
votes
2answers
164 views

Unable to concatenate files with find ./subdir/* -print0 | sort | xargs -0 cat > merge.txt

I am trying to concatenate thousands of files that result from processing the pieces output by split with find ./subdir/* -print0 | sort | xargs -0 cat > full_merge.txt The files under subdir ...
4
votes
2answers
169 views

Sort files by modification time

I've seen many questions and answers here using a construction along the lines of list_dir=`ls -t /path/to/dir/` for i in $list_dir; do or ls -t | while read i; do Now, I know that you shouldn't ...
3
votes
1answer
73 views

find utility does not recognize bracket notation

I've two files in the current folder: submitWeb.m submit.m the following find does not show the two files: find . -regex .*submit\(Web\)?\.m But the above regex expression works fine in ...
1
vote
3answers
2k views

List all files in a directory recursively but exclude directories themselves

Simple question, I'm running the following find command: find . -type d \( -path ./.git -o -path ./log -o -path ./public -o -path ./tmp \) -prune -o -print To list all the files in my directory, ...
1
vote
3answers
64 views

Variable scope in multiple pipes

I was trying to do something following, find . -name "*.dat" | get the basename of file | move filename returned by first command to basename returned by second command To give a concrete example, ...
2
votes
4answers
83 views

find command: how to ignore pathname?

I have to find some type of files in a directory and it's subdirectories and I only have to print out the filenames. So here's the main command: find -type f -name "*.c" Now, how could I cut the ...
3
votes
3answers
324 views

Concatenating thousands of files: > vs >>

I found two seemingly contradictory answers on StackOverflow to the following questions: Concatenating Thousands of Text Files Across Hundreds of Directories (while keeping some structure) How do I ...
1
vote
3answers
443 views

Setting file permissions in bash script

This script is not working the way I thought it would .I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5 #!/bin/bash # the / makes find ...
2
votes
2answers
284 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
70 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
2k 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
220 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 ...
2
votes
4answers
1k 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 ...
9
votes
1answer
240 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
91 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
157 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
779 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
99 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
177 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
115 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
767 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
163 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
739 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
701 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
436 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
1k 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
700 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
379 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
217 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
331 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 ...
5
votes
3answers
307 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 ...
24
votes
5answers
7k 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
131 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 ...
2
votes
4answers
236 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
524 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
165 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
502 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 ...
5
votes
5answers
970 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
196 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
478 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
77 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 ...
1
vote
1answer
92 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
790 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
128 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
0
votes
4answers
773 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
170 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
609 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 ...
9
votes
1answer
690 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
127 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
209 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 ...