linux grep 用法

筆記種類
redhat
grep 用法

要用正則表達式
要使用E 及將條件包在"[]"中進行

redmaple@localhost:~$ sudo grep -rE "[P|p]assword" /etc/
(挑出有P/p兩種password)

redmaple@localhost:~$ sudo grep -rE "redmaple" /etc/
/etc/shadow-:redmaple:!:20430:0:99999:7:::
/etc/group:wheel:x:10:redmaple
/etc/group:redmaple:x:1000:
/etc/gshadow:wheel:::redmaple
/etc/gshadow:redmaple:!::
/etc/passwd:redmaple:x:1000:1000:redmaple:/home/redmaple:/bin/bash
/etc/shadow:redmaple:$y$j9T$mp76HslyzAT5Mtu4HIbAf.$6RKPEZejNzeAXBAXeaFItSVd2WrR5coznWwNve5SgmB:20430:0:99999:7:::
/etc/subgid:redmaple:524288:65536
/etc/subuid:redmaple:524288:65536
/etc/cups/subscriptions.conf.O:Owner redmaple
/etc/cups/subscriptions.conf:Owner redmaple

redmaple@localhost:~$ sudo grep -rlE "redmaple" /etc/
/etc/shadow-
/etc/group
/etc/gshadow
/etc/passwd
/etc/shadow
/etc/subgid
/etc/subuid
/etc/cups/subscriptions.conf.O
/etc/cups/subscriptions.conf