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

learn more… | top users | synonyms

1
vote
1answer
159 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
309 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
119 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
91 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
104 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
116 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
69 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
62 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
69 views

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

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
118 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
29 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
42 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
853 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
40 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 ...
0
votes
1answer
144 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
56 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
72 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
74 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 ...
4
votes
4answers
217 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
51 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 ...
3
votes
3answers
125 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
64 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 ...
2
votes
2answers
71 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
127 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
55 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
54 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
57 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" >> ...
5
votes
2answers
83 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
81 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
44 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
83 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
50 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/ ...
1
vote
4answers
181 views

How do I search for all the folders that begin with a dot ( . )?

My server had been infected and the attacker spread a bunch of .5randomletters folders around my file system, with malicious code inside of them. I want to search for all the folders that begin with a ...
2
votes
3answers
106 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
46 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
74 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
96 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
57 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
609 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
65 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
122 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
3answers
335 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 ...
3
votes
2answers
771 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 ...
4
votes
2answers
85 views

Find file names that don't contain a specified string

I'd like to execute the opposite of: find . -name "*2013*" Find all the files in the current directory that don't contain the string "2013" in their names. How can I do that?
3
votes
2answers
159 views

`find` with multiple `-name` and `-exec` executes only the last matches of `-name`

When I'm using find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt" it finds all the types of file. But when I add -exec at the end: find . -type f -name "*.htm*" -o -name "*.js*" -o ...
2
votes
3answers
135 views

how to pipe find's output into another find

In searching how to make find sort the files it finds based on modification time I found this answer which provides the following incantation: find . -type f -printf '%T@ %p\n' | sort -k 1nr | sed ...
0
votes
1answer
51 views

Finding a specific file in several sub-directories

I've the following problem : I have to write something to copy a file contained in directory A. The file is unique, and has a specific extension (.jil). Only problem, directory A can contains a ...
2
votes
1answer
83 views

Check for existence of files prior to acting on them

In one of my processes I check for existence of files older than 31 days, and then do stuff with them. find /my/directory/*txt -mtime +31 -exec ls -l {} \; All this is well and fine if files are ...
6
votes
1answer
116 views

How does the order of arguments influence the speed of find

How does the order of arguments in a find call affect the speed of the results? Compare for example (A) find -name dir -type d and (B) find -type d -name dir Or any other of combinations of ...
0
votes
2answers
70 views

How can I for example list five largest files in /usr/lib -directory?

How can I for example list five largest files in /usr/lib directory? Please also add some minor explanation for each bit of code that you are using.