IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Need help with a find/grep
I'm trying to do a recursive find/grep from a directory on my linux box. Normally, I can do this no problem. This time, however, there are spaces in some directory names. I didn't create these dirs, and I don't really have control over them -- they're for another project that I'm not working directly on, but need to grep the source code.

So, my command looks something like:

find . -type f -print | grep -v -e stuff_i_dont_want | xargs grep -l what_im_looking_for

I use tcsh, but can switch to another shell if it will get me what I'm looking for.

Since there are spaces in some directory names, I get a ton of spam that looks like this:

grep: ./part/of/path: No such file or directory
grep: rest/of/path/file.txt: No such file or directory


So, in essence, the file it's trying to grep is:

"./part/of/path rest/of/path/file.txt"

Grep thinks that is two different files, and then it can't find either one when it splits on the space.

Thunks?
-YendorMike

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
- Benjamin Franklin, 1759 Historical Review of Pennsylvania
New Ahh. You need to inline some replacments
find . -type f -print | grep -v -e stuff_i_dont_want | xargs grep -l what_im_looking_for
Will never work properly due to "typical delimiters honored" in *NIX/Linux

Basically whe I know there are funky things going on I do an in-line replacement, this specific one should help you.

find . -type f -print | sed -es/\\ /\\\\\\\\\\ /g | grep -v -e stuff_i_dont_want | xargs grep -l what_im_looking_for

Basically you have to use a double escape on a double escape to get it right for commands further down the line.

Heres hoping.
--
[link|mailto:greg@gregfolkert.net|greg],
[link|http://www.iwethey.org/ed_curry|REMEMBER ED CURRY!] @ iwethey
Freedom is not FREE.
Yeah, but 10s of Trillions of US Dollars?
SELECT * FROM scog WHERE ethics > 0;

0 rows returned.
Expand Edited by folkert March 31, 2006, 06:54:59 PM EST
New [ ] is your friend?
New Use the -r switch to grep
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Yeah, I could...
But more often than not, my find . -type f -print is more properly typed as find . -name "*.java" -print or something similar. So find . (something) just naturally comes out.

Truth is, I'd forgotten about grep -rl what_im_looking_for *.

*sheepish grin*
-YendorMike

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
- Benjamin Franklin, 1759 Historical Review of Pennsylvania
     Need help with a find/grep - (Yendor) - (4)
         Ahh. You need to inline some replacments - (folkert)
         [ ] is your friend? -NT - (ChrisR)
         Use the -r switch to grep -NT - (ben_tilly) - (1)
             Yeah, I could... - (Yendor)

'Cause the music rules.
48 ms