I'm trying to do a recursive grep on a directory while excluding all the .svn folders. How can I do this? I've read about the -exclude-dirs but I don't seem to have that available on my system.
Thanks!
Megan
My web design blog
I'm trying to do a recursive grep on a directory while excluding all the .svn folders. How can I do this? I've read about the -exclude-dirs but I don't seem to have that available on my system.
Thanks!
Megan
My web design blog
Megan posted this at 20:22 — 29th June 2009.
She has: 10,998 posts
Joined: Jun 1999
This works:
grep -iR "string" * | grep -v ".svn"Megan posted this at 19:33 — 30th June 2009.
She has: 10,998 posts
Joined: Jun 1999
What if I want to exclude more than one directory? Say,
.svnandlog?Abhishek Reddy posted this at 21:42 — 30th June 2009.
He has: 3,348 posts
Joined: Jul 2001
Try ack. Your two searches would look something like this:
ack -ai "string"ack -ai --ignore-dir=log "string"By default, it ignores .svn and other common version-control or backup cruft. Also, it defaults to a recursive search (use -n to prevent that).
Btw, on Debian the program is called
ack-grep-- may not be the same on your distro.abhishek.geek.nz
Megan posted this at 15:12 — 2nd July 2009.
She has: 10,998 posts
Joined: Jun 1999
"command not found"
Abhishek Reddy posted this at 15:53 — 2nd July 2009.
He has: 3,348 posts
Joined: Jul 2001
It's not likely to have been installed by default. Try adding it with your package manager. On Debian or Ubuntu:
$ sudo aptitude install ack-grep$ ack-grep --help
Usage: ack [OPTION]... PATTERN [FILE]
Search for PATTERN in each source file in the tree from cwd on down....
abhishek.geek.nz
Megan posted this at 15:59 — 2nd July 2009.
She has: 10,998 posts
Joined: Jun 1999
I don't have root access on this server. Maybe I'll have to bug the sys admins to either install this or upgrade grep.
JeevesBond posted this at 13:29 — 1st July 2009.
He has: 3,893 posts
Joined: Jun 2002
How about:
find . -not -path '*/.svn*' | xargs grep -i "string"ack seems interesting. (offtopic) are you a Debian man now Abhi?
a Padded Cell our articles site!
Abhishek Reddy posted this at 20:05 — 1st July 2009.
He has: 3,348 posts
Joined: Jul 2001
I have been using Debian mainly since at least early 2007, maybe even 2006 if memory serves.
abhishek.geek.nz
JeevesBond posted this at 19:06 — 2nd July 2009.
He has: 3,893 posts
Joined: Jun 2002
Hmmm, that means we've been acquanted for quite a while. You used to use Gentoo, if memory serves.
That would have been back in 2005/6 we were talking about such things.
a Padded Cell our articles site!