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
7328
votes
55 answers

How to find all files containing specific text (string) on Linux?

How do I find all files containing a specific string of text within their file contents? The following doesn't work. It seems to display every single file in the system. find / -type f -exec grep -H 'text-to-find-here' {} \;
Nathan
  • 73,987
  • 14
  • 40
  • 69
2087
votes
46 answers

How do I exclude a directory when using `find`?

How do I exclude a specific directory when searching for *.js files using find? find . -name '*.js'
helion3
  • 34,737
  • 15
  • 57
  • 100
937
votes
21 answers

How can I exclude all "permission denied" messages from "find"?

I need to hide all permission denied messages from: find . > files_and_folders I am experimenting when such message arises. I need to gather all folders and files, to which it does not arise. Is it possible to direct the permission levels to the…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
909
votes
14 answers

Find a value in a list

I use the following to check if item is in my_list: if item in my_list: print("Desired item is in list") Is "if item in my_list:" the most "pythonic" way of finding an item in a list? EDIT FOR REOPENING: the question has been considered…
Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
761
votes
14 answers

Does a "Find in project..." feature exist in Eclipse IDE?

Does Eclipse have a way to search a whole project for some text like Xcode's "find in project" feature?
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
730
votes
18 answers

How do I find files that do not contain a given string pattern?

How do I find out the files in the current directory which do not contain the word foo (using grep)?
Senthil Kumar
  • 9,695
  • 8
  • 36
  • 45
682
votes
7 answers

Find duplicate lines in a file and count how many time each line was duplicated?

Suppose I have a file similar to the following: 123 123 234 234 123 345 I would like to find how many times '123' was duplicated, how many times '234' was duplicated, etc. So ideally, the output would be like: 123 3 234 2 345 1
user839145
  • 6,883
  • 3
  • 16
  • 10
638
votes
26 answers

How can I get a recursive full-path listing, one line per file?

How can I spit out a flat list of recursive one-per-line paths? For example, I just want a flat listing of files with their full…
dreftymac
  • 31,404
  • 26
  • 119
  • 182
621
votes
14 answers

find -exec with multiple commands

I am trying to use find -exec with multiple commands without any success. Does anybody know if commands such as the following are possible? find *.txt -exec echo "$(tail -1 '{}'),$(ls '{}')" \; Basically, I am trying to print the last line of each…
Andy
  • 6,219
  • 3
  • 15
  • 3
505
votes
7 answers

Find a file by name in Visual Studio Code

How can I find a file by name in Visual Studio Code? A Visual Studio shortcut I'm used to is CTRL+,, but it does not work here.
Nenad
  • 24,809
  • 11
  • 75
  • 93
425
votes
12 answers

Using find to locate files that match one of multiple patterns

I was trying to get a list of all python and html files in a directory with the command find Documents -name "*.{py,html}". Then along came the man page: Braces within the pattern (‘{}’) are not considered to be special (that is, find . -name…
Xiong Chiamiov
  • 13,076
  • 9
  • 63
  • 101
413
votes
9 answers

How to use regex with find command?

I have some images named with generated uuid1 string. For example 81397018-b84a-11e0-9d2a-001b77dc0bed.jpg. I want to find out all these images using "find" command: find . -regex "[a-f0-9\-]\{36\}\.jpg". But it doesn't work. Is something wrong…
thoslin
  • 6,659
  • 6
  • 27
  • 29
405
votes
8 answers

How can I find elements by text content with jQuery?

Can anyone tell me if it's possible to find an element based on its content rather than by an ID or class? I am attempting to find elements that don't have distinct classes or IDs. (Then I then need to find that element's parent.)
sisko
  • 9,604
  • 20
  • 67
  • 139
405
votes
15 answers

Make xargs handle filenames that contain spaces

$ ls *mp3 | xargs mplayer Playing Lemon. File not found: 'Lemon' Playing Tree.mp3. File not found: 'Tree.mp3' Exiting... (End of file) My command fails because the file "Lemon Tree.mp3" contains spaces and so xargs thinks it's two…
showkey
  • 482
  • 42
  • 140
  • 295
393
votes
17 answers

How to loop through file names returned by find?

x=$(find . -name "*.txt") echo $x if I run the above piece of code in Bash shell, what I get is a string containing several file names separated by blank, not a list. Of course, I can further separate them by blank to get a list, but I'm sure there…
Haiyuan Zhang
  • 40,802
  • 41
  • 107
  • 134
1
2 3
99 100