匹配整個單詞

給出一個檔案 sample:

hello world
ahello here
hello_there

hello 的正常 grep 返回:

$ grep hello sample 
hello world
ahello here
hello_there

使用 -w 可以選擇那些包含構成整個單詞的匹配的行:

$ grep -w hello sample 
hello world