![]() ![]() You may want to try this to see what happens otherwise. ![]() If you wanted to find all words containing the pattern "nn," you would have to type: $ grep 'nnn*' list However, if you wanted to find all words containing the letter "n," you would have to type: $ grep 'nn*' list Suppose you want to find all words with the letters "qu" in them. When an asterisk ( *) follows a character, grep interprets it as "zero or more instances of that character." When the asterisk follows a regular expression, grep interprets it as "zero or more instances of characters matching the pattern."īecause it includes zero occurrences, usage of the asterisk is a little non-intuitive. Would match any three characters with "an" as the first two, including "any," "and," "management," and "plan" (because spaces count, too). And the command: $ grep '^b$' listĭisplays any line in list where "b" is the only character on the line. The command: $ grep 'b$' listĭisplays any line in which "b" is the last character on the line. So the command: $ grep '^b' listįinds any line in the file list starting with "b."Ī dollar-sign ( $) indicates the end of the line. * $ ? and \) with a backslash ( \).Ī caret ( ^) indicates the beginning of the line. Whenever you use a grep regular expression at the command prompt, surround it with quotes, or escape metacharacters (such as
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |