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

learn more… | top users | synonyms

3
votes
3answers
387 views

Which command to use to find all files/folders with non-default permissions?

Suppose I have a folder, containing other files and folders, and I'd like to find out recursively which subfiles and subfolders have non-default permissions (i.e., not 644 or 755). Which command can ...
0
votes
2answers
123 views

Finding all .cpp and .h files and moving them to ~/junk

I created a folder on my home directory call junk, and let's say I want to move all .cpp and .h files to it. How would I do it? My first thought is to start with find ~ -name *.cpp -print, but I don't ...
1
vote
4answers
46 views

Find files on disk that match a really long text list of files

I have a list of tens of thousands of file names. I want to find which of those files actually exist on disk (in a particular directory). I'm not sure how to start. I could try it with either Python ...
1
vote
3answers
129 views

How to use the pipe command to open a directory after find?

Is there a way to opend found directories (via find) all in one command? One of the things I tried to study several times and never been able to really get, is the effective use of pipe: is it maybe ...
3
votes
1answer
77 views

-not -name does not work with find

I am trying to use find/grep to find some text patterns in my code base. I want to exclude non-source directories into which my build process duplicates source files: find . -name *.java -not -name ...
3
votes
1answer
196 views

find/grep outputs two lines for each file it finds match

I search my code base to find string patterns and list all the files where the pattern is found but only the file and not the lines on which it is found: find . -name *.java -exec grep -l 'someText' ...
4
votes
2answers
119 views

In Linux Fedora, How can I select files to move by time interval

How can I select and move files that were written in a specified time interval, such as 1530 to 1730 local time on a recent date? Background: I use Linux Fedora 12, and I have made my first, and long ...
1
vote
1answer
662 views

Basename gives extra operand error

I 'm using the following script to merge few pcap files into one using mergecap command. But when I run it it gives me a 'basename: extra operand /mnt/md0/capture/DCN/dcn_2014_02_04_00_11_47_598.pcap' ...
4
votes
3answers
365 views

Using find command to find folder ignoring case

I would like to know if a particular folder is present or not. I used the following command find /mnt/md0/ -maxdepth 1 -name 'dcn'||'DCN' I want to know if folder name is DCN or dcn . How would I ...
1
vote
2answers
289 views

Find duplicate file names with specific matching pattern

I have a folder with some files (snippet of the contents of the folder) PAT1.URGRSVP.50.WR786842JOB11632.WRS20140.FILE0005.DAT PAT1.URGRSVP.50.WR786842JOB11643.WRS20140.FILE0003.DAT ...
3
votes
2answers
2k views

Get list of subdirectories which contain a file matching a string

How can I get a list of the subdirectories which contain a file matching a particular string? More specifically, I am looking for directories which contain a file with the letter 'f' somewhere ...
0
votes
2answers
112 views

Deleting large number of files

I'm writing a script to delete large number of files in linux. The script will run every two minutes in crontab. I tried using the find /mnt/md0/capture/DCN/ -maxdepth 1 -type f -name "*.pcap" ...
3
votes
2answers
413 views

Save find -exec output to text file

I have a set of videos in the folder. I would like to get the info about this videos using ffmpeg -i command and save the output to file. So I wrote the line: find . -type f -exec ffmpeg -i {} \; ...
2
votes
4answers
258 views

print parent directories full path of find output

what I want to do is to find all files based on some search query and get parents parent directory (../..) full path. For example find . -name "__openerp__.py" and then for each file execute ...
4
votes
2answers
274 views

Find files newer than another file within each subdirectory

I have a folder structure like this /Class/Student/Unit/files Each Unit folder contains a file MarkSheet* that I update when I mark a students work. I need a script that tests if the student has ...
-1
votes
4answers
102 views

Need a command sequence that will move files from one directory to another based on a particular year? [duplicate]

I'm looking for a sequence of commands (one liner would be ideal) which will identify all the files created in particular year, and move the resulting files to another directory.
2
votes
4answers
204 views

Using a generated list of filenames as argument list — with spaces

I'm trying to invoke a script with a list of filenames collected by find. Nothing special, just someting like this: $ myscript `find . -name something.txt` The problem is that some of the pathnames ...
1
vote
1answer
44 views

find: prune does not ignore specified path

I need to exclude .git from my find search. To achive that, I am using the -path ./.git -prune switch: $ find . -path ./.git -prune -o \( -type f -o -type l -o -type d \) | grep '.git' ./.git ...
2
votes
1answer
167 views

Combining options in find command

Using the find command is there a way to combine options: i.e. find . -type fd -name "somefile" Although -type ignores the second option; I'm looking to find only files or directories.
9
votes
3answers
2k views

identify files with non-ASCII or non-printable characters in file name

In a directory size 80GB with approx 700,000 files, there are some file names with non-English characters in the file name. Other than trawling through the file list laboriously is there: An easy ...
0
votes
1answer
186 views

How to escape spaces while using command's output in command line [duplicate]

I want to perform the following command in command line : $ md5sum $(find . -type f) But this would cause problems when it encounter files with spaces in filenames : md5sum: Kaufmann: No such ...
2
votes
1answer
2k views

find + grep to match exact keywords in a file

My script is not matching exact words only. Example: 12312312Alachua21321 or Alachuas would match for Alachua. KEYWORDS=("Alachua" "Gainesville" "Hawthorne") IFS=$'\n' find . -size +1c -type f ! ...
2
votes
2answers
89 views

help with truncate \ find

This command won't work: $ truncate -s 0 $(find . -size +1c type -f -exec grep -LwE 'keyword1|keyword2|keyword3' {} +) "find: paths must precede expression: type Usage: find [-H] [-L] [-P] [-Olevel] ...
1
vote
2answers
163 views

How to execute a builtin shell command using find?

I'm constrained to doing this in tcsh on CentOS due to the environment at work. When executing find . -type f -executable -exec source '{}' \; the only result is find: 'source': No such file or ...
5
votes
3answers
198 views

Mac OS X find/grep generating “unknown --devices option”

I am entering a command I have done often with Linux, Unix perfectly fine but with Apple Mac OS X 10.8 (and probably before) I get a grep: unknown --devices option when I attempt to run the following ...
2
votes
1answer
92 views

How to FILTER the files with filename and then DELETE the OLDEST file from there? [duplicate]

I create and keep the following automated backup files e.g.: fruits_29-12-2013.gz fruits_30-12-2013.gz fruits_31-12-2013.gz sweets_01-12-2013.gz sweets_02-12-2013.gz sweets_03-12-2013.gz .. ...
4
votes
4answers
225 views

Locating files and displaying their owner

I have to search for a specific file type on a storage unit and also want to know their owners. With locate '*.txt' >> result.txt I find all files I'm looking for but I'm missing the owner this ...
1
vote
2answers
86 views

visit all directories under version control

Is there a find incantation that would allow me to visit all directories under SVN version control? I am trying to use the execdir switch to add to the svn:ignore property in each one of these ...
4
votes
3answers
474 views

find with execdir

I run a find with execdir both I don't get the results I was expecting. SSCCE below: mkdir -p a/b/c find . -type d -execdir touch foo \; $ tree a a ├── b │   ├── c │   └── foo └── foo Directory c ...
3
votes
5answers
90 views

Omit the target dir from find results

How can I prevent find from returning the directory I use as the root to start searching from in the results? e.g.: $ find targetDir -name 'target*' targetDir/target1 targetDir/target2 ...
3
votes
2answers
338 views

How do I make find follow most, but not all, symbolic links?

My OS and home directory are on an SSD. I store some large files on a hard disk, and symlink from my home directory to the hard disk (eg. ~/Videos/Films is a symlink to /mnt/hdd/Films). I also have a ...
0
votes
2answers
324 views

Tail multiple files and output as additional column with 'find' results

Would like to pull the last line of text from a specific (multiple) files in a directory. Additionally, I'd like the results to be in a more traditional column format (like ls) with path, rather than ...
1
vote
1answer
69 views

Running 'diff 'command after the 'find' command

I'm running this code on shell mv -f ~/sites/text1.txt ~/sites/text2.txt;find ~/sites/ -type f -exec sha1sum {} >> ~/sites/text.txt \;diff ~/sites/text1.txt ~/sites/text2.txt; However every ...
0
votes
3answers
109 views

apply specific command for each git repository

I want compress all the git repositories on my computer (say in ~). I.e., for each directory {}, that contains directory or file (in case of submodules) named .git, I want to execute git gc ...
2
votes
2answers
86 views

Pipeline with grep and find prints numbers infront of result

Am using the following "find" command to extract some files, find /lag/cnnf/ -maxdepth 3 -newer ./start ! -newer ./end | grep -nri abc | egrep '([^0-9]45[^0-9])' | grep -nri "db.tar.gz" >> ...
6
votes
2answers
359 views

Delete files specified by the output of find: rm thinks argument list is too long.

When I run the following command, it gives me an error: $ rm -f `find /home/domain/imap/domain.com/*/Maildir -mtime +190 | grep -E '/cur/|/new/'` -bash: /bin/rm: Argument list too long How can I ...
2
votes
2answers
146 views

Understanding -regex with GNU find

Background I have what I think should be a simple case. I want to find all files with "cisco" in the name and do something with those files (via xargs). Finding files with ls Before I use xargs, ...
2
votes
1answer
49 views

size option in find(version 4.4.2) does not understand kilo prefix

For some reason, find does not seem to accept kilobytes prefix: T42 ~ # find /root/ /home/noc/ \( -type f -size -1k \) -exec grep -iH hangup {} \; find: `/home/noc/.gvfs': Permission denied T42 ~ # ...
2
votes
3answers
106 views

The processing order and printing of files with find

This simple BASH script collects msgstrs in a PHP project: #!/bin/sh TARGET=/path/to/project LPATH=locale/cy_GB/LC_MESSAGES POFILE=messages.po mkdir -p $LPATH touch $TARGET/$LPATH/$POFILE cd $TARGET ...
2
votes
3answers
67 views

using regex with find

Let's say I need to find all files in /var/log/ except btmp, lastlog, wtmp. And I only need depth 1. I tried with the following find command, but that does not work as expected: find /var/log/ ...
2
votes
3answers
443 views

“find” output relative to directory

I'd like to use find to list all files and directories recursively in a given root for a cpio operation. However, I don't want the root directory itself to appear in the paths. For example, I ...
1
vote
2answers
60 views

How to find a symlink when the location in which it was created is unknown?

I followed some slightly incorrect instructions to install my video driver. I executed this command blindly and don't know what directory I did it: sudo ln -s lib /usr/lib64 How can I find that ...
1
vote
2answers
141 views

Find on AIX with output to file

find /apps/dynalife/clients/. ! -path "train" -type f -mtime +90 ! \( -name "*.p" -o -name "*.i" -o -name "*.w" -o -name "*.cls" -o -name "*.inf" -o -name "*.bat" \) -exec {} \; > ...
1
vote
3answers
169 views

Prevent wildcard expansion on find

Is there a way to prevent wildcard expansion on the find command so that the following would work? find . -iname "foo [bar]" As pointed out here, I tried running set -f, set -o noglob and setopt ...
1
vote
2answers
70 views

double-quoting parameter (representing filename) doesn't help if spaces are contained

When iterating over some filenames double-quoting the parameter does not prevent the filename from being broken: $ mkdir temp $ cd temp/ $ touch a\ b $ for f in $(find .) ; do echo "$f" ; done . ./a ...
4
votes
6answers
1k views

ls with find :: report total size

I am trying to get the total size of files satisfying a find, e.g.: ls $(find -maxdepth 2 -type f) However, this kind of invocation of ls does not produce the total size as well.
3
votes
3answers
87 views

How do I search all subdirectories to find one with a certain name?

Let's say I have a top level directory called /dir and many sub directories. How do I search the subdirectories of /dir to find the one called x/x/dir/x/x/x/target? This question is similar to, but ...
3
votes
1answer
138 views

Find directories with a certain name

How can I loop through each directory recursively and whenever it finds a folder called VIDEO_TS, let Genisoimage convert that folder's content to an dvd-video iso image, the name of the iso would be ...
4
votes
4answers
1k views

What is the most efficient way to move a large number of files that reside in a single directory?

CentOS 5.x I apologize if this is a repeat question. I've seen a lot of similar questions (regarding deleting files) but not exactly the same scenario. I have a directory containing hundreds of ...
4
votes
2answers
7k views

Remove all files created before a certain date

I have a directory containing a high number of files (like logs for every day of the year). I would like to remove all files created before let's say 22/11. How can I achieve that ? Must I use find ...