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
259
votes
7 answers

MongoDB Show all contents from all collections

Is it possible to show all collections and its contents in MongoDB? Is the only way to show one by one?
Reno
  • 2,639
  • 2
  • 12
  • 7
256
votes
5 answers

How to exclude this / current / dot folder from find "type d"

find . -type d can be used to find all directories below some start point. But it returns the current directory (.) too, which may be undesired. How can it be excluded?
Matthias Ronge
  • 9,403
  • 7
  • 47
  • 63
255
votes
15 answers

How to pipe list of files returned by find command to cat to view all the files

I am doing a find to get a list of files. How do I pipe it to another utility like cat so that cat displays the contents of all those files? Afterwards, I'd use grep on that to search some text in those files.
Devang Kamdar
  • 5,617
  • 8
  • 24
  • 16
255
votes
14 answers

'find -exec' a shell function in Linux

Is there a way to get find to execute a function I define in the shell? For example: dosomething () { echo "Doing something with $1" } find . -exec dosomething {} \; The result of that is: find: dosomething: No such file or directory Is there a…
alxndr
  • 3,851
  • 3
  • 34
  • 35
253
votes
6 answers

Chmod recursively

I have an archive, which is archived by someone else, and I want to automatically, after I download it, to change a branch of the file system within the extracted files to gain read access. (I can't change how archive is created). I've looked into…
user797257
248
votes
7 answers

Visual Studio Clicking Find Results Opens Code in Wrong Window

I'm using Visual Studio 2010 and when I do a "Find in Files" the results are returned to the "Find Results 1" window which is docked below my code editor window. Before, I would double click on one of the results in the Find Results window and the…
JPM
  • 2,481
  • 2
  • 14
  • 3
235
votes
19 answers

How can I get `find` to ignore .svn directories?

I often use the find command to search through source code, delete files, whatever. Annoyingly, because Subversion stores duplicates of each file in its .svn/text-base/ directories my simple searches end up getting lots of duplicate results. For…
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
225
votes
12 answers

How to go to each directory and execute a command?

How do I write a bash script that goes through each directory inside a parent_directory and executes a command in each directory. The directory structure is as follows: parent_directory (name could be anything - doesnt follow a pattern) 001…
Van de Graff
  • 5,043
  • 13
  • 39
  • 41
224
votes
3 answers

Find all files with a filename beginning with a specified string?

I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of files. I have tried ls mystring* but this returns with the bash error 'Too…
RikSaunderson
  • 3,505
  • 6
  • 32
  • 50
223
votes
6 answers

Using semicolon (;) vs plus (+) with exec in find

Why is there a difference in output between using find . -exec ls '{}' \+ and find . -exec ls '{}' \; I got: $ find . -exec ls \{\} \+ ./file1 ./file2 .: file1 file2 testdir1 ./testdir1: testdir2 ./testdir1/testdir2: $ find . -exec ls …
Ankur Agarwal
  • 23,692
  • 41
  • 137
  • 208
212
votes
7 answers

How can I check if character in a string is a letter? (Python)

I know about islower and isupper, but can you check whether or not that character is a letter? For Example: >>> s = 'abcdefg' >>> s2 = '123abcd' >>> s3 = 'abcDEFG' >>> s[0].islower() True >>> s2[0].islower() False >>> s3[0].islower() True Is…
O.rka
  • 29,847
  • 68
  • 194
  • 309
208
votes
10 answers

How to use find command to find all files with extensions from list?

I need to find all image files from directory (gif, png, jpg, jpeg). find /path/to/ -name "*.jpg" > log How to modify this string to find not only .jpg files?
Kirzilla
  • 16,368
  • 26
  • 84
  • 129
196
votes
5 answers

Find and copy files

Why does the following does not copy the files to the destination folder? # find /home/shantanu/processed/ -name '*2011*.xml' -exec cp /home/shantanu/tosend {} \; cp: omitting directory `/home/shantanu/tosend' cp: omitting directory…
shantanuo
  • 31,689
  • 78
  • 245
  • 403
194
votes
6 answers

Find files containing a given text

In bash I want to return file name (and the path to the file) for every file of type .php|.html|.js containing the case-insensitive string "document.cookie" | "setcookie" How would I do that?
Owen
  • 7,347
  • 12
  • 54
  • 73
182
votes
10 answers

Search for executable files using find command

What type of parameter/flag can I use with the Unix find command so that I search executables?
well actually
  • 11,810
  • 19
  • 52
  • 70