5

My Linux version is 2.6.32-47-server (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) ) #109-Ubuntu SMP Tue May 7 02:17:05 UTC 2013

I am currently doing a tail -f file and life is good. But that only shows the last X lines. Is it possible for tail to first display the whole file and then behave like tail -f?

I tried tail -500 -f file but that gave me tail: option used in invalid context -- 1
In a sense, it would be like cat file; tail -f file; But showing only the lines that were not displayed since the cat

Is it possible?

2 Answers2

5

That's simply:

tail -fn+1 file

-f to follow, -n+1 for tail to start from the first line (the beginning of the file).

  • Could you explain the command. I realise that -f follows new updates, but what does the n+1 mean? – Heather Mar 31 '15 at 09:16
2

Another solution is to use the follow feature in less.

less -f file

You can enter follow mode in less by pressing Shift+f. Ctrl+c exits follow mode at which point the less functionality is returned.