Linux grep 多个条件搜索: 技巧与示例
在 Linux grep 中,可以使用 '|' 符号来表示或者条件。例如,要查找包含 'hello' 或 'world' 的行,可以使用以下命令:/n/n/ngrep 'hello/|world' filename/n/n/n其中,'/|' 表示或者条件,需要使用 '//' 来转义。/n/n另一种方法是使用 '[]' 符号来表示或者条件。例如,要查找包含 'hello' 或 'world' 的行,可以使用以下命令:/n/n/ngrep '[hello|world]' filename/n/n/n其中,'[]' 表示或者条件,可以包含多个字符。但是,需要注意的是,'|' 符号在 '[]' 中不需要转义。
原文地址: https://www.cveoy.top/t/topic/fXeO 著作权归作者所有。请勿转载和采集!