Grep
grep -w 有什麼作用?
在這裡grep 與選項一起使用
-w
。我做了man grep
並grep --help
試圖找到上述選項的作用。兩個輸出都沒有說明-w
選項。該選項有什麼作用?為什麼它沒有出現在
man
or中--help
?如果類似的事情再次發生,我還能在哪裡檢查答案?我目前正在使用 Ubuntu,如果相關的話(是嗎?)
# grep --help | grep -e -w -w, --word-regexp force PATTERN to match only whole words -H, --with-filename print file name with output lines -L, --files-without-match print only names of FILEs with no selected lines -l, --files-with-matches print only names of FILEs with selected lines # grep PRETTY /etc/os-release PRETTY_NAME="Ubuntu 18.04 LTS" # man grep | grep -e -w -A1 -w, --word-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.