Software >> OS >> Unix >> Commands >> grep >> How to use - grep

 

# grep key1.*key2 <file>           search 2 keywords with logical AND match
# grep -w <key> <file>              search with whole word matching
# grep [xyz]key <file>                 search for "key" prefixed with either x or y or z.
# grep [0-9]key <file>                search for "key" prefixed with any char within range specified by [ ]
# grep _[0-9][0-9]_                    search _nn_ where n represents any digit between 0 to 9

Last updated on (yyyy-mm-dd): 2008-01-14