我正在尝试grep进行tail文件日志并n从一行中获取第th 个单词。示例文件:
$ cat > test.txt <<EOL
Beam goes blah
John goes hey
Beam goes what?
John goes forget it
Beam goes okay
Beam goes bye
EOL
^C
Run Code Online (Sandbox Code Playgroud)
现在,如果我做一个tail:
$ tail -f test.txt
Beam goes blah
John goes hey
Beam goes what?
John goes forget it
Beam goes okay
Beam goes bye
^C
Run Code Online (Sandbox Code Playgroud)
如果我grep认为tail:
$ tail -f test.txt | grep Beam
Beam goes blah
Beam goes what?
Beam …Run Code Online (Sandbox Code Playgroud)