11. Regular Expressions

1. Cut interception with: split and retain the seventh segment
grep hadoop /etc/passwd | cut -d: -f7

2. Sort
du | sort -n  3. Query grep -v hadoop /etc/passwd

that does not contain hadoop 4. Regular The expression contains hadoop grep 'hadoop' /etc/passwd 5. Regular expression (dot represents any character) grep 'h.*p' /etc/passwd 6. Regular expression starts with hadoop grep '^hadoop' /etc/passwd 7 .regex ends with hadoop grep 'hadoop$' /etc/passwd rules: . : any one character a* : any number of a (zero or more a) a? : zero or one a a+ : one or more a .* : any number of arbitrary characters \. : escape. \<h.*p\> : a word starting with h and ending with p o\{2\} : o repeated twice grep '^i. \{18\}n$' /usr/share/dict/words Find lines not starting with # grep -v '^#' a.  txt | grep -v '^$' 





























grep starting with h or r
'^[hr]' /etc/passwd

not grep starting with h and r
'^[^hr]' /etc/passwd

not grep starting with h to r
'^[^hr] ' /etc/passwd

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324689236&siteId=291194637