- ps -x | grep "rpc.nfsd"
finds the process titled "rpc.nfsd"
Where a program needs an extra filename, there is a bug in grep that it won't give the name of the file where they find a match unless there are at least two filenames on the command line. Use /dev/null to ensure that grep will always see more than one :
# grep "whatever" * /dev/null
- -l -->
- -i --> case insensitive
- grep ` ADS' input_file
searchs for the word ADS, as it is preceded by a space
- grep -r quote *
my favorite, use it so often: does a recursive search for that word across directoris. If there are spaces, use quotes around your search term
- ps -aux |grep bin |grep -v grep|awk '{print $1;}'
finds user owning process containing keyword "bin"
- -v says "select non-matching lines" or invert it not-to-search instead
grep -lr quote *
print filenames of matches, not actual line
- --binary-files=TYPE, for example grep -r --binary-files=without-match va_ *
skip matches in binary files
- --exclude=PATTERN
Recurse in directories skip file matching PATTERN.
this grep is the only one that supports syntax like egrep '(John|Fred)' phone.txt
- egrep Beyer|SBM input_file
- really does just look for either Beyer or SBM
- no square brackets required
egrep [0-9]\{3,0\} input_file
- searches for a span of three or more numbers 0 to 9
return to top