当我做
tail -f file.log
Run Code Online (Sandbox Code Playgroud)
在bash中,文件的每个更改都显示在屏幕上.但不是列出文件的每一行,而是只想显示包含特殊字符串的行special string.所以我试过了
grep 'special string' file.log | tail -f
Run Code Online (Sandbox Code Playgroud)
但是此命令会立即返回到bash,而不会显示文件中的任何未来更改.
怎么做正确?
tail -f file.log | grep 'special string'
Run Code Online (Sandbox Code Playgroud)
很简单,呵呵:)
您的订单的问题是grep没有"跟随"的尾部能力.