
我使用的是 Ubuntu 16.04
試:
grep '.*' file1
輸出:
file nu-mber o-ne second string
試:grep '.+' file1
輸出缺失
為什麼 plus 不行?
答案1
答案2
使用 GNU grep(Ubuntu 上預設),您也可以使用反斜線啟用擴充行為。例如:
grep '.\+' file1
答案3
我相信 + 是一個擴展的正則表達式元字元。嘗試使用egrep
.
我使用的是 Ubuntu 16.04
試:
grep '.*' file1
輸出:
file nu-mber o-ne second string
試:grep '.+' file1
輸出缺失
為什麼 plus 不行?
使用 GNU grep(Ubuntu 上預設),您也可以使用反斜線啟用擴充行為。例如:
grep '.\+' file1
我相信 + 是一個擴展的正則表達式元字元。嘗試使用egrep
.