Questions tagged [find]

The find command in Windows systems is used to filter lines of input text, and return those matching the filter. The find command in *nix system is used to locate files or folders that match a certain criteria.

Two different find commands are present in *nix and Windows systems.

  • On *nix systems, find searches for files(folders, links...) in a directory hierarchy. [Wiki]. [Linux man].

    find . -name 'my*'
    
  • On Windows systems, find is used to filter lines of input text, and return those matching the filter. [Wiki]

    C:\>find "keyword" < inputfilename > outputfilename
    

Usage

Use this tag for questions about how to use the find command, in either Windows or *nix systems. This includes questions on command line parameters, and general usage questions. Because find is similar (but difference) between Windows and *nix, you can also use this tag for compatibility questions, and about differences between versions and software environments.

If your questions is not specifically about how to use the find command line utility, and is more generally about how to find files or search file contents, please use one of the related tags below.

Related tags

1061 questions
342
votes
5 answers

How can I find files that are bigger/smaller than x bytes?

In a terminal, how can I find files that are bigger or smaller than x bytes? I suppose I can do something like find . -exec ls -l {} \; and then pipe the result to awk to filter by file size. But shouldn't there be an easier way than this?
ceiling cat
  • 4,737
331
votes
10 answers

How do I find a file by filename in Mac OSX terminal?

I want to find a file on my Macbook with the filename: abc.dmg. I've tried to use spotlight, but it doesn't find it. When I tried find, and used: find -name abc.dmg -path /, I got errors back. What is the proper syntax to find a file by filename…
SPRBRN
  • 8,149
293
votes
20 answers

Unix/Linux find and sort by date modified

How can I do a simple find which would order the results by most recently modified? Here is the current find I am using (I am doing a shell escape in PHP, so that is the reasoning for the variables): find '$dir' -name '$str'\* -print | head -10 How…
Richard Easton
241
votes
5 answers

How to ignore certain filenames using "find"?

One of my favorite BASH commands is: find . -name '*.*' -exec grep 'SearchString' {} /dev/null \; which searches the contents of all of the files at and below the current directory for the specified SearchString. As a developer, this has come in…
Cody S
  • 2,684
225
votes
9 answers

How can I find only the executable files under a certain directory in Linux?

How can I find only the executable files under a certain directory in Linux?
168
votes
6 answers

Invoking vi through find | xargs breaks my terminal. Why?

When invoking vim through find | xargs, like this: find . -name "*.txt" | xargs vim you get a warning about Input is not from a terminal and a terminal with pretty much broken behaviour afterwards. Why is that? This question was explicitly about…
DevSolar
  • 4,560
142
votes
5 answers

Delete matching files in all subdirectories

How can I remove all .swp files in all of my subdirectories under Linux?
Alex
  • 2,601
132
votes
5 answers

Finding files which contain a certain string using find (1) and grep (1)

find . -type f -print -exec cat {} \; | grep some string Command above doesn't print the file path. I'm using: Ubuntu, bash 4.
H.Rabiee
  • 1,423
  • 2
  • 10
  • 7
128
votes
5 answers

How can I search a file by its name and partial path?

Often I have a file name and it's partial path, e.g. "content/docs/file.xml". Is there a simple way to search for that file, without manually cutting into parts its name to provide directory name and file name separately? It'd be great if find…
user69817
123
votes
2 answers

How to search for ? (question mark) in Excel

When I try to find the question mark character (?) in an Excel sheet, Excel cannot locate the cells containing them. How can I search for ? in Excel?
102
votes
8 answers

How can I recursively copy files by file extension, preserving directory structure?

At the Linux command line, I'd like to copy a (very large) set of .txt files from one directory (and its subdirectories) to another. I need the directory structure to stay intact, and I need to ignore files except those ending in .txt.
100
votes
3 answers

Case Insensitive search from find command?

I am not able to figure out how can I do case-insensitive search using the find command. I tried find . -name -i pattern And it does not work.
74
votes
10 answers

Equivalent of Unix find command on Windows

What is the equivalent of the Unix find command on Windows? I see that the find.exe on Windows is more like a grep. I am especially interested in the equivalent of find . -name [filename]
ARV
  • 965
63
votes
5 answers

How do I execute multiple commands when using find?

I'm trying to run multiple commands on things I have found, how can I achieve this? find . -exec cmd1; cmd2 does not seem to work; it instead runs cmd2 after cmd1 has been executed on every file.
63
votes
4 answers

Find files filtered by multiple extensions

What is the correct syntax for: find . -type f -name \*.\(shtml\|css\) This works, but is inelegant: find . -type f -name \*.shtml > f.txt && find . -type f -name \*.css >> f.txt How to do the same, but in fewer keystrokes?
Dave Jarvis
  • 3,427
1
2 3
70 71