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