Search code examples
tail

tail -f starting with the entire file


I would like to follow a file but tail -f always starts with the last 10 lines. Is there a way to output the entire file then follow?

My goal is to find all occurrences of a string in a log, such as tail -f streaming_log | grep "string". But also include all previous line.

I know I can do tail -f -n 10000 file but I don't want to count the lines first.


Solution

  • -n +<line> allows you to specify a starting line (1-based):

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