2017-05-06 134 views
2

我想跟隨一個文件,但tail -f總是從最後10行開始。有沒有辦法輸出整個文件,然後按照?tail -f從整個文件開始

我的目標是在日誌中查找所有匹配的字符串,例如tail -f streaming_log | grep "string"。但也包括以前的所有行。

我知道我可以做tail -f -n 10000 file但我不想先計算行數。

回答

3

-n +<line>允許你指定一個開始線(1爲基礎):

tail -f -n +1 file # output entire file, then wait for new content