If I have two lines of text:
HOOK
HOOK HOOK
what is the syntax to grep just the first line without the second? and the second without the first?
Find any difference between both and then match it.
e.g. with HOOK by itself in a line we can match the beginning and end of the line. Thus:
Once you have down the successful match the opposite will work in this case, using the -v switch.
grep -v '^HOOK$' file_name
Will match HOOK HOOK
However, if there were another line containing something that is not
^HOOK$ it will produce a match as well.
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Offline 2,304 posts
since Dec 2006