View Full Version : how to make grep ignore special characters

July 7th, 2008, 11:24 PM
usually i use grep to search long man pages for certain options rather than going through the whole manual..however when i need to view the part related to certain option, grep interprets that option as its own which causes unexpected behaviour or displaying available options for grep..for instance i need to check what -r exactly does in userdel as in

man userdel | grep -r
now grep modifies its behaviour accordingly, but i need it to search for -r in the man page instead..

man grep | grep exact
ddnt really help :)
any suggestions ??

July 7th, 2008, 11:29 PM
man userdel | grep -- -r-- = end options

man userdel | grep -A 10 -- -r

-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching lines.
Places a line containing a group separator (--) between
contiguous groups of matches. With the -o or --only-matching
option, this has no effect and a warning is given.

July 8th, 2008, 11:32 AM
thx, this solves the problem.
now how can i search for a sequence of words, like

man grep | grep "end options"
preferably case insensitive search

July 8th, 2008, 11:39 AM
man grep | grep -i -A 3 -- "--IgnorE-CasE"

July 8th, 2008, 09:54 PM
I hope this will work:

man userdel | grep '\-r'

July 10th, 2008, 08:07 PM
thx guys..u rock