Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Systems > Linux / BSD / OS X
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 10-01-2007, 01:46 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
grep > (only print lines without CVS)

i want to make a report of all files in my system that use the word 'foo'. i do not want results that have /CVS in the path to be added.

i figure i should be able to pipe the info and filter it out, but i'm not sure how. here's the command.

Code:
$ grep -R foo ./ >> log.txt
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 10-02-2007, 03:17 AM   #2 (permalink)
ShadyCraig
Recruit
 
Join Date: Sep 2005
Location: Loughborough, England, UK
Posts: 12
ShadyCraig is on a distinguished road
Try:
Code:
$ grep -Rl foo ./ | grep -v "CVS/" >> log.txt
l (thats 'ell') just means list the files that match, the second grep then removes anything with CVS in the path or filename but the / means that it should only match paths

grep has a --exclude option but it seems only to work on the filename not the path.

Shady
__________________
ShadyCraig is offline   Reply With Quote
Old 10-02-2007, 08:31 AM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I always love the find/xargs combo for this sort of thing:
Code:
find -not -name CVS -print0 |xargs -0 grep foo
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 10-02-2007, 03:53 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
well that makes sense .. thanks a lot!
__________________
testing 1 2 3
sde is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OOP logic?? Noogie Program Design and Methods 10 10-13-2006 06:36 PM
what language is this? sde All Other Coding Languages 10 05-25-2004 03:57 PM


All times are GMT -8. The time now is 07:29 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle