我正在 grep 命令的输出,并且希望只返回特定的、严格的结果。
我记得 grep 的某些迭代有一个严格的选项-s
/ --strict
。
例如,grep -s bytes
只会返回提到单词“bytes”的条目,而不是每个单词包含字节,如“兆字节”、“千字节”等。
答案1
-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.