Command to find file with text
Hello there,
is there a command in Linux to find a file (searching in the whole disk) with some text (of the file) which I will explicit in the search? something like: find "text inside the file" in all the files Thanks! x:tisk: |
hmm....haven't done ever (as finding all the files on one's disk takes a hell of a long time ;) heheh) but here's some starting things:
"cat" prints out the contents of a file, like "cat foo.txt" prints what's inside foo.txt and "cat /*/*" might then print out everything in everywhere? not sure. "grep" cuts off and prints only the parts that are given, for example "cat foo.txt | grep you" would first read through file foo.txt, then print out every line which has the string "you" inside it (like you, you're, yours, fdsajlkfdsyoufdlask and so on) :) I don't know any ready program...perhaps there is, perhaps not. You might want to try combining different commands to success.... |
Hi,
I would use something like Code:
grep -R -e <regexp-pattern> / |
Is there a way to search through a folder of files, find the phrase you're looking for and then show the file name? :scratch:
|
find <dir> -name "name"
ex find /home/user/mp3 -name "*trance*.mp3" |
gnome search tool can do this if your after a gui (command "gnome-search-tool")
|
I'm using Darwin so, no gnome gui for me. - not quite what I'm looking for delta - I want to show the name of the file that contains the string.
|
yeah do a man grep (or just grep --help) and it'll show you how.
|
Code:
find . -name *.txt | xargs grep -l 'text-to-find' ... where . is the directory specification (this one starts at the current directory) ... where *.txt is the filespec of files to search ... where 'text-to-find' is the text you want to find inside thefiles. But sometimes you'll find so many files it'll scroll away. Here's what I do: Code:
find . -name *.txt | xargs grep -l 'text-to-find' | gvim - |
if only I could pipe that to the "why I love linux" thread :)
|
Brilliant! Thank you. I just did a | more at the end of it. Thanks all!
|
All times are GMT -5. The time now is 05:22 AM. |