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.

learn more… | top users | synonyms

186
votes
6answers
121k views

How to chmod 755 all directories but no file (recursively)?

How to chmod 755 all directories but no file (recursively) ? Inversely, how to chmod only files (recursively) but no directory ?
44
votes
12answers
54k views

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): ...
43
votes
4answers
47k views

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 ...
43
votes
3answers
47k views

How to find the executable files under a certain directory in linux?

How to find the executable files under a certain directory in linux?
36
votes
5answers
5k views

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 ...
33
votes
4answers
29k views

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 ...
31
votes
3answers
13k views

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.
30
votes
6answers
49k views

Bash script to delete files older than x days with subdirectories

I'm trying to delete a ton of files older than x days. Now I have a script to do that find /path/to/files* -mtime +10 -exec rm {} \; But this will also delete the subdirectories. There are a ton ...
29
votes
5answers
1k views

Deleting millions of files

I had a dir fill up with millions of gif images. Too many for rm command. I have been trying the find command like this: find . -name "*.gif" -print0 | xargs -0 rm Problem is, it bogs down my ...
28
votes
3answers
23k views

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.
20
votes
4answers
26k views

Delete matching files in all subdirectories

How can I remove all .swp files in all of my subdirectories under Linux?
19
votes
4answers
24k views

Find all files on server with 777 permissions

I'm looking for a Linux command to go through all the directories on my server and find all files with 777 permission. The output would be a list of all those files with full path.
19
votes
3answers
12k views

Exclude hidden files when searching with Unix/Linux find?

What options do I need to use with find to exclude hidden files?
15
votes
2answers
6k views

How can I use '{}' to redirect the output of a command run through find's -exec option?

I am trying to automate an svnadmin dump command for a backup script, and I want to do something like this: find /var/svn/* \( ! -name dir -prune \) -type d -exec svnadmin dump {} > {}.svn \; ...
14
votes
9answers
21k views

Copy all files and folders excluding subversion files and folders on OS X

I'm trying to copy all files and folders from one directory to another, but exclude certain files. Specifically, I want to exclude subversion files and folders. However, I'd like a general yet ...
13
votes
2answers
18k views

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?
13
votes
4answers
10k views

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 ...
13
votes
3answers
14k views

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 ...
12
votes
8answers
3k views

Is it possible to find a printer's physical location in a building by its IP adress?

I am in a school with probably 200+ computers and I did an IP scan among a certain range and found three or four printers. I was wondering if it would be possible to find these printers in the school, ...
12
votes
3answers
6k views

How to use ack to search for file name

I have started using ack which is much faster than grep. However using ack I want to search for file name rather than file contents. Is there a way to do that?
12
votes
5answers
3k views

How to run sed on over 10 million files in a directory?

I have a directory that has 10144911 files in it. So far I've tried the following: for f in ls; do sed -i -e 's/blah/blee/g' $f; done Crashed my shell, the ls is in a tilda but i can't figure out ...
12
votes
4answers
24k views

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 ...
11
votes
8answers
12k views

Making BASH script `for` handle filenames with spaces (or workaround)

Whilst I have been using BASH for several years, my experience with BASH scripting is relatively limited. My code is as below. It should grab the entire directory structure from within the current ...
11
votes
4answers
7k views

Ubuntu grep, find etc: “Permission denied” and “No such file or directory” output

When I grep or find something I always get annoyed by the "Permission denied" and "No such file or directory" notice, smth like that: johndoe@johndoe-desktop:/$ grep -rnP 'YII_CORE_PATH' ./ | grep -v ...
11
votes
3answers
22k views

Linux find folder inside subfolders

I am trying to find a directory named 480debugerror nested under child directories. I don't know the exact path, or even if I have the exact spelling of the directory I want to find. Is there a Linux ...
11
votes
3answers
3k views

Is there any way of making Ctrl+f in Chrome use the selected text, as per Firefox?

One thing that's really bugged me since switching to Chrome is that Ctrl + F behaves slightly differently from Firefox. In Firefox, if you have text highlighted and hit Ctrl + F, it'll start finding ...
10
votes
2answers
10k views

How to Combine find and grep for a complex search? ( GNU/linux, find, grep )

I'm trying to do a text search in some files that share a similar directory structure, but are not in the same directory tree, in GNU/Linux. I have a web server with many sites that share the same ...
10
votes
3answers
4k views

Using `find` for multiple file extensions

I am using the following command for counting the lines of text in JAVA files: find . -name '*.java' | xargs wc -l How can I modify the find command parameters to match more than one file ...
10
votes
3answers
17k views

What's the difference between the find and findstr commands in Windows?

In Windows, what are the differences between the find and findstr commands? Both seem to search for text in files: find C:\> find /? Searches for a text string in a file or files. FIND [/V] ...
10
votes
5answers
6k views

How to count total number of lines of found files?

I'm running a find . -name pattern to find some files, and I'd like to elegantly get the total number of lines in these files. How can I achieve that?
10
votes
1answer
8k views

How can I force only relative paths in “find” output?

I am attempting to create a script that can compress files with a certain extension in a number of directories into a single tar-ball. Currently what I have in the script file is: find "$rootDir" ...
9
votes
2answers
888 views

Is there any way to find similar files (not duplicates)?

My final goal is refactoring code written by my coworkers. So, is there a tool which can find files differing in only few words? (Edit: this is for a Mac, but others might like non-Mac answers too.)
8
votes
2answers
777 views

Why backslash before asterisk in `find`?

In this command: find . -name \*.pyc -delete Why is a backslash needed before *.pyc ?
8
votes
3answers
3k views

avoid permission denied spam when using find-command

I often try to find files with following syntax: find . -name "filetofind" However it usually results as many rows or error reporting (Permission denied) about folders where permission is denied. ...
8
votes
2answers
4k views

find command doesn't seem to work in cygwin

When trying to run find commands in cygwin, I keep getting the error "FIND: Parameter format not correct" However, the same commands run on linux. What's going on?
8
votes
5answers
8k views

How to list all source files (*.c, *.cpp, *.h)

I'd like to find source files (*.c, *.cpp, *.h) that contain in Linux/MinGW/Cygwin, and recursively in all sub directories. My basic idea is using find and grep. However, building a regular ...
8
votes
1answer
3k views

find / grep command without searching mounted shares

When I used the find command, I almost always need to search the local drives. But, I almost always have super large network shares mounted and these are included in the search. Is there an easy way ...
7
votes
5answers
8k views

Linux command to find files changed in last n seconds.

I would like a Linux command to find files changed in last n seconds. Is there a shell script or other tool that I can run from command line interface or gui?
7
votes
4answers
8k views

find: -exec vs xargs (aka Why does “find | xargs basename” break?)

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via basename, but it did't work ...
7
votes
4answers
6k views

How do I parse the output of the find command when filenames have spaces in them?

Using a loop such as for i in `find . -name \*.txt` will break if some filenames have spaces in them. What technique can I use to avoid this problem?
7
votes
2answers
115 views

Is -print a useless option for find now?

I just tried : find . -name "*.[hc]" -print and find . -name "*.[hc]" But both output the same ,is -print useless now?
7
votes
7answers
12k views

Using Windows Explorer, how to find file names starting with a dot (period), in 7 or Vista?

I've got a MacBook laptop in the house, and when Mac OS X copies files over the network, it often brings along hidden "dot-files" with it. For instance, if I copy "SomeUtility.zip", there will also ...
7
votes
7answers
5k views

Find all files that are NOT of a specific type/extension in folder?

Windows 7 Ultimate 64bit: I'm looking for a way to find all the files in a directory that are NOT of a specific file type or extension. Example: I'd like to find every file that isn't an .mp3 in my ...
7
votes
2answers
7k views

Faster alternatives to “find” and “locate”?

I will like to use "find" and locate" to search for source files in my project, but they take a long time to run. Are there faster alternatives to these programs I don't know about, or ways to speed ...
7
votes
3answers
7k views

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 ...
6
votes
6answers
5k views

find command in Linux to locate pdf files

My goal is to find all pdf files on a remote machine, so I resort to the useful command find. So I type find ~ *.pdf or find ~ "*.pdf" and I get nothing. I do the same on my machine and I get nothing. ...
6
votes
3answers
2k views

Linux: How can I edit all the files returned by find in vi?

Something I find myself doing a lot is running a find command and then editing all of them in vi, which looks something like this: > find . "*.txt" ./file1.txt ./file2.txt ./path/to/file3.txt ...
6
votes
3answers
8k views

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.
6
votes
3answers
6k views

How-to limit Unix FIND results number

Is there a way to limit the number of results returned by the FIND command on an unix system? We are having performance issue due to an unsually large number of files in some directories. I'm tryging ...
6
votes
5answers
5k views

Is there a smarter Find files utility for Windows 8 than Windows key + F?

Is there any utility for Windows 8 that will basically do the same thing the old "Find" dialog in Explorer did? Often times (many times a day) I need to find a particular file, and I don't know the ...