grep
'fred' /etc/passwd
This command searches
for all occurrences of the text string 'fred' within the "/etc/passwd" file. It will find and print (on
the screen) all of the lines in this file that
contain the text string 'fred', including lines that contain
usernames like "fred" - and also "alfred".
grep
'^fred' /etc/passwd
This command searches
for all occurrences of the text string 'fred' within the "/etc/passwd" file, but also requires that the
"f" in the name "fred" be in the first column of each
record (that's what the caret character tells grep). Using this more-advanced search, a
user named "alfred" would not be matched, because the
letter "a" will be in the first
column.
grep
'joe' *
This command searches
for all occurrences of the text string 'joe' within all files of the current
directory.
|