want to display lines starting with the string "root"
grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
Pattern | What does it match? | |||
---|---|---|---|---|
bag | The string bag. | |||
^bag | bag at beginning of line. | |||
bag$ | bag at end of line. | |||
^bag$ | bag as the only word on line. | |||
[Bb]ag | Bag or bag. | |||
b[aeiou]g | Second letter is a vowel. | |||
b[^aeiou]g | Second letter is a consonant (or uppercase or symbol). | |||
b.g | Second letter is any character. | |||
^...$ | Any line containing exactly three characters. | |||
^\. | Any line that begins with a dot. | |||
^\.[a-z][a-z] | Same, followed by two lowercase letters (e.g., troff requests). | |||
^\.[a-z]\{2\} | Same as previous, grep or sed only. | |||
^[^.] | Any line that doesn't begin with a dot. | |||
bugs* | bug, bugs, bugss, etc. | |||
"word" | A word in quotes. | |||
"*word"* | A word, with or without quotes. | |||
[A-Z][A-Z]* | One or more uppercase letters. | |||
[A-Z]+ | Same, egrep or awk only. | |||
[A-Z].* | An uppercase letter, followed by zero or more characters. | |||
[A-Z]* | Zero or more uppercase letters. | |||
[a-zA-Z] | Any letter. | |||
[^0-9A-Za-z] | Any symbol (not a letter or a number). | a^c |
0 comments:
Post a Comment