如何在 linux 中模拟旧的 unix grep -S 严格功能

Nat*_*ord 2 linux grep centos

我正在搜索命令的输出,我希望只返回特定的、严格的结果。

我记得 grep 的一些迭代有一个严格的选项-s/ --strict

例如,grep -s bytes只会返回提到“字节”一词的条目,而不是每个包含字节的词,如“兆字节”、“千字节”等。

jj3*_*j33 7

   -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 con-
          stituent character.  Word-constituent characters are
          letters, digits, and the underscore.
Run Code Online (Sandbox Code Playgroud)

  • 是的,我运行“man grep”并搜索“word”的能力确实是传说中的东西=) (8认同)