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

142
votes
6answers
92k 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 ?
35
votes
12answers
44k 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): ...
34
votes
3answers
40k 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?
33
votes
4answers
37k 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 ...
29
votes
5answers
41k 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
3answers
24k 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 ...
28
votes
5answers
835 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 ...
24
votes
5answers
4k 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 ...
24
votes
3answers
10k 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.
23
votes
3answers
19k 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.
18
votes
4answers
21k views

Delete matching files in all subdirectories

How can I remove all .swp files in all of my subdirectories under Linux?
17
votes
2answers
10k 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
4k views

Why is it so hard to find a file in Ubuntu?

It's very hard to find files in Ubuntu. In Windows, you could just go to C:\Program Files and you would find what you need. In Ubuntu, you must use search to find something you need. Maybe I am ...
15
votes
4answers
20k 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.
14
votes
9answers
20k 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 ...
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
4answers
8k 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 ...
12
votes
2answers
5k 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 \; ...
11
votes
3answers
5k 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?
11
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 ...
11
votes
2answers
10k 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?
10
votes
8answers
11k 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 ...
10
votes
3answers
20k 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 ...
9
votes
3answers
14k 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] ...
9
votes
3answers
2k 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 ...
9
votes
5answers
5k 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?
9
votes
2answers
815 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.)
9
votes
1answer
6k 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" ...
8
votes
2answers
756 views

Why backslash before asterisk in `find`?

In this command: find . -name \*.pyc -delete Why is a backslash needed before *.pyc ?
8
votes
4answers
17k 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 ...
8
votes
2answers
9k 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 ...
8
votes
3answers
2k 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
3answers
3k 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 ...
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
4answers
7k 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
5k 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 ...
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
4answers
5k 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
4answers
7k 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 ...
7
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?
6
votes
5answers
4k 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
5answers
7k 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?
6
votes
7answers
10k 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 ...
6
votes
3answers
5k 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
7answers
4k 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 ...
6
votes
3answers
5k 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
2answers
5k 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 ...
6
votes
1answer
2k views

Linux find/search root partition ONLY?

Say I need to do: find / -name somefile.txt and say root partition / is mounted on /dev/sda5; however, let's say I also have 250GB partitions (/dev/sda6, /dev/sda7) mounted in /media - AND ...
6
votes
3answers
2k views

How do I run this `find` command, but only on non-binary files?

I want to remove trailing whitespace from all the files in a recursive directory hierarchy. I use this: find * -type f -exec sed 's/[ \t]*$//' -i {} \; This works, but will also remove trailing ...
6
votes
1answer
17k views

DOS Batch file to find “new” files by date

My PC has entered an infinite BSOD loop - but I do have access to a safe-mode command prompt. I'm trying to get an idea of "what changed" that might have triggered this. e.g. I might have gotten a ...