Grep: Difference between revisions

From Hackepedia
Jump to navigationJump to search
No edit summary
 
m requires optimization
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
If you want to grep for two strings?  say fish OR fowl in your file:
If you want to grep for two strings?  say fish OR fowl in your file:


  $ egrep 'fish|fowl' file
  $ egrep '(fish|fowl)' file
 
To show all lines that do not start with a # (commented out):
 
# grep -v ^# /etc/inetd.conf
 
If you want to search for the some string resursively through subdirectories:
 
$ grep . -name "*" | xargs grep "some string"
 
(someone please optimize the above)

Latest revision as of 12:25, 21 October 2007

If you want to grep for two strings? say fish OR fowl in your file:

$ egrep '(fish|fowl)' file

To show all lines that do not start with a # (commented out):

# grep -v ^# /etc/inetd.conf

If you want to search for the some string resursively through subdirectories:

$ grep . -name "*" | xargs grep "some string"

(someone please optimize the above)