Results 1 to 5 of 5
hi,
I am trying to find a phrase inside a bounce of documents inside a specific folder.
Is there any program (like a text editor) or a unix command so ...
- 04-15-2008 #1
program or unix command that finds patern on documents of a folder?
hi,
I am trying to find a phrase inside a bounce of documents inside a specific folder.
Is there any program (like a text editor) or a unix command so I can retrieve every document that contains the specific phrase inside that folder?
Thanx in advance
- 04-15-2008 #2
If all the files are in plain text, and you're looking for the phrase "my_phrase", the following might be what you need,
This will search every file in the current folder, and every folder beneath it, for files containing the string "my_phrase".Code:find ./ | xargs grep my_phrase
Let us know if that helps.Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 04-15-2008 #3Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
- 04-15-2008 #4Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 04-15-2008 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
No problem.
Your approach is *mostly* correct, though a bit more complicated. It has one problem though: if the argument list get too big it will fail.
In that, case, you *must* use grep -r, or if you like the pipe approach, use a while loop to read all the values:
This should work always, regardless of the number of files being listed by 'find'.find ./ | while read file; do grep <string> "$file"; done


Reply With Quote
