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

learn more… | top users | synonyms

1
vote
2answers
80 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
348 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
85 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
256 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
257 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
65 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
101 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
80 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
259 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
138 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
98 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
62 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
327 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
57 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
124 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
148 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
68 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
929 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
85 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
5k 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
205 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?
4
votes
2answers
279 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
207 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
74 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
99 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
135 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
87 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.
0
votes
1answer
113 views

How can I pass in a parameter to sed?

To be more precise - how can I pass in a parameter to a program that then calls sed - how can I 'pass' that parameter along? I have a file 'source_code.sc'. I have a sed script "find_expect": #n ...
2
votes
2answers
164 views

Use xargs to move files from within a directory

I am searching for some folders in my current directory. What I want to do is, move all the files within those directories to another directory. I am using the following command: find -maxdepth 1 ...
1
vote
1answer
144 views

Copying wallpaper images into a single folder

In my ubuntu 12.04 set-up, there are lots of wallpaper images in the directory /usr/share/wallpapers. For example, one might be usr/share/wallpapers/Leafs_Labyrinth/contents/images/1600x1200.jpg ...
1
vote
2answers
150 views

Count entries for each directory in tree

Say I have the following tree: root: d foo d bar /foo: d A - tmp.txt /bar: d B - tmp2.txt /foo/A: - tmp3.txt /bar/B: d = directory and - = file I need to answer the following question: which ...
2
votes
1answer
58 views

Linux shell - unexpected error

I'm new to the linux & command world. I have two directories, one called pasta (which contains 3 files) and another one called pasta2 (with nothing inside). I'm trying to move all 3 files from ...
2
votes
2answers
85 views

What is the “initialization time” in the find command?

When I try to refer find command's man page , I come across -mmin n The value of n can be one of the following: n Evaluates as True if the file modification time ...
0
votes
3answers
170 views

thoroughly find all links (hard and symlinks, and any combination thereof) leading to a file/dir

I read "most" of the proposed questions, but I believe they all miss the complexity of the right answer. I want, only using "basic" commands (for maximum portability) (i.e., something that would work ...
2
votes
2answers
98 views

Trouble getting regex to work with find

I'm having a lot of trouble getting find to work with regex flags. Im using egrep on its own to find a date pattern in a file, like this: egrep '[0-9]{4}-[0-9]{2}-[0-9]{2}' which will return dates ...
3
votes
3answers
172 views

Find directories without music files

My ~/Music/ directory is actually full of "empty" directories I want to clean. I say "empty" because this directories actually contain files, some contain old cover image files or Thumbs.db files. I ...
1
vote
1answer
125 views

Find a particular nesting of directory names, e.g. …/project/dir1/dir2

I'm having some issues dealing with the find command; I don't know the syntax for it very well and I need to use it in a script to find a specific directory structure that could be located anywhere. ...
4
votes
2answers
110 views

Linux splitting array into separate variables

I've been programming on MVS for years and recently have been using Linux so my Linux skills are not that great yet but I understand development concepts well. What I'm trying to do is to read a ...
3
votes
2answers
254 views

Create Zip for each subfolder but containing only matched files

I am trying to figure out how to create a zip file for each subfolder containing only files that match my criteria. For instance I have: Folder1 Folder2 Folder3 Each folder contains the same set ...
1
vote
2answers
317 views

Need to copy files to existing directory and remove files already there with the same name but different extension

EDIT: Total rewrite of question for clarity. I have a directory tree (new) with a bunch of files of with an extension of .new. I have an identical tree (old) where many of the files have names ...
4
votes
1answer
124 views

why does find command use {} for a placeholder variable?

I'm curious as to why find uses {} as the syntax for variable substitution (e.g., as in find . -name "*~" -exec rm {} \;). It's a rather unusual syntax, and I don't know any other programs or ...
3
votes
2answers
137 views

find: combining -path and -prune to exclude files and directories

I have a directory /srv/tftp/pxelinux.cfg and a file /etc/mtab. I want to exclude both from find. But whatever I do, either one always is not excluded find /etc /srv -path /srv/tftp/pxelinux.cfg ...
4
votes
3answers
123 views

What is the difference between [.]* and '.*' for command 'find -name'?

My goal is to find all files or directories in a filesystem that start with a dot (.), for example .gnupg. So I came up with the command: find -name '.*' Checking on the Internet, I saw some hints ...
2
votes
2answers
84 views

Rationale find command display . directory

I am wondering what the reason or rationale is for the find command to list the current directory ( . ) at some times but not others. When I use ".", I see the current directory in the outer ...
5
votes
5answers
2k views

Faster way to delete large number of files

I have a directory where lots of cached files are getting generated very quickly. Since these are very small files, it is consuming all my inodes very quickly. Currently I am running the following ...
1
vote
2answers
198 views

mv complains about standard input in a pipeline that filters file name with grep

I'm trying to move several .avi files that have spaces in from a CD to my home folder. I've already know how to get rid of the spaces: find /media/mathscd/ | grep -L -r "*.avi" | for file in *; do ...
3
votes
2answers
2k views

find files not matching list of filename patterns

I find myself needing to find and identify extraneous files (out of about 900K files on a 2T drive). There are lots of files that I want to keep, and I have filename patterns for these known good ...