我有文本文件.我需要打印这些包含特定字符串的行,例如:文本文件:
Car, bold 231212 /Fds
House pen 232123 /RYF
game kon 342442 /ksgj
mess three 42424 /UTR
Run Code Online (Sandbox Code Playgroud)
我需要保持行包含Fds或UTR
输出:
Car, bold 231212 /Fds
mess three 42424 /UTR
Run Code Online (Sandbox Code Playgroud)
如何在grep中执行这些操作?
谢谢
尝试这样做,OR运营商的管道: |:
grep -E 'Fds|UTR' file
Run Code Online (Sandbox Code Playgroud)
要么
grep -E '(Fds|UTR)' file
Run Code Online (Sandbox Code Playgroud)
要么
grep -P '(?:Fds|UTR)' file
Run Code Online (Sandbox Code Playgroud)
要么
grep 'Fds\|UTR' file
Run Code Online (Sandbox Code Playgroud)