Questions tagged [find]

This tag has multiple meanings. Please DO NOT use this tag if you're just trying to find something.

find is:

  1. a filesystem search tool on various flavors of *nix,
  2. a filesystem search tool on various flavors of DOS and Windows,
  3. the name of a jQuery method,
  4. the name of a family of methods in ActiveRecord,
  5. a function in the C++ standard library,
  6. a method of strings in Python,
  7. a method of Matcher Class in Java.
  8. a method in many different NoSQL's to find documents in a collection.
11183 questions
384
votes
8 answers

How do I find all of the symlinks in a directory tree?

I'm trying to find all of the symlinks within a directory tree for my website. I know that I can use find to do this but I can't figure out how to recursively check the directories. I've tried this command: find /var/www/ -type l … and later I…
hafichuk
  • 10,351
  • 10
  • 38
  • 53
384
votes
11 answers

Fast way of finding lines in one file that are not in another?

I have two large files (sets of filenames). Roughly 30.000 lines in each file. I am trying to find a fast way of finding lines in file1 that are not present in file2. For example, if this is file1: line1 line2 line3 And this is…
Niels2000
  • 4,027
  • 3
  • 16
  • 15
354
votes
10 answers

How to only get file name with Linux 'find'?

I'm using find to all files in directory, so I get a list of paths. However, I need only file names. i.e. I get ./dir1/dir2/file.txt and I want to get file.txt
marverix
  • 7,184
  • 6
  • 38
  • 50
346
votes
7 answers

Find the files that have been changed in last 24 hours

E.g., a MySQL server is running on my Ubuntu machine. Some data has been changed during the last 24 hours. What (Linux) scripts can find the files that have been changed during the last 24 hours? Please list the file names, file sizes, and modified…
JackWM
  • 10,085
  • 22
  • 65
  • 92
339
votes
7 answers

How to check if a value exists in a dictionary?

I have the following dictionary in python: d = {'1': 'one', '3': 'three', '2': 'two', '5': 'five', '4': 'four'} I need a way to find if a value such as "one" or "two" exists in this dictionary. For example, if I wanted to know if the index "1"…
JimmyK
  • 4,801
  • 8
  • 35
  • 47
331
votes
6 answers

Error when using 'sed' with 'find' command on OS X: "invalid command code ."

Being forced to use CVS for a current client and the address changed for the remote repo. The only way I can find to change the remote address in my local code is a recursive search and replace. However, with the sed command I'd expect to work: find…
helion3
  • 34,737
  • 15
  • 57
  • 100
302
votes
9 answers

How to use 'find' to search for files created on a specific date?

How do I use the UNIX command find to search for files created on a specific date?
sverrejoh
  • 16,464
  • 13
  • 41
  • 29
297
votes
21 answers

How can I find WPF controls by name or type?

I need to search a WPF control hierarchy for controls that match a given name or type. How can I do this?
alex2k8
  • 42,496
  • 57
  • 170
  • 221
296
votes
9 answers

"find: paths must precede expression:" How do I specify a recursive search that also finds files in the current directory?

I am having a hard time getting find to look for matches in the current directory as well as its subdirectories. When I run find *test.c it only gives me the matches in the current directory. (does not look in subdirectories) If I try find . -name…
Chris Finley
  • 3,901
  • 5
  • 24
  • 32
294
votes
13 answers

find: missing argument to -exec

I was helped out today with a command, but it doesn't seem to be working. This is the command: find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 && rm {}\; The shell returns find: missing argument to `-exec' What I am…
Abs
  • 56,052
  • 101
  • 275
  • 409
284
votes
21 answers

How to recursively find the latest modified file in a directory?

It seems that ls doesn't sort the files correctly when doing a recursive call: ls -altR . | head -n 3 How can I find the most recently modified file in a directory (including subdirectories)?
JMW
  • 7,151
  • 9
  • 30
  • 37
283
votes
3 answers

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. In this case I want to look in all .bar files in the current directory, searching for the term FOO find . -name '*.bar' -exec grep -Hn FOO {} \;
Allan Thomas
  • 3,481
  • 5
  • 26
  • 29
282
votes
4 answers

find without recursion

Is it possible to use the find command in some way that it will not recurse into the sub-directories? For example, DirsRoot |-->SubDir1 | |-OtherFile1 |-->SubDir2 | |-OtherFile2 |-File1 |-File2 And the result of something like…
filippo
  • 5,583
  • 13
  • 50
  • 72
275
votes
10 answers

How to use '-prune' option of 'find' in sh?

I don't quite understand the example given from the man find, can anyone give me some examples and explanations? Can I combine regular expression in it? The more detailed question is like this: Write a shell script, changeall, which has an…
derrdji
  • 12,661
  • 21
  • 68
  • 78
269
votes
9 answers

find filenames NOT ending in specific extensions on Unix?

Is there a simple way to recursively find all files in a directory hierarchy, that do not end in a list of extensions? E.g. all files that are not *.dll or *.exe UNIX/GNU find, powerful as it is, doesn't seem to have an exclude mode (or I'm missing…
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233