Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to display whole file before tracking it for a new changes, not only the last 10 lines (yep, I know it's not tail conceptually). In other words, something like cat -f would do, if it would ever existed. Tail's man doesn't give me any ideas. The only option I see right now is to somehow combine cat all but last 10 lines and tail -f output.

Any hints, please?

share|improve this question
3  
cat $f && tail -n0 -f $f comes to mind, and checking the man page it looks like tail -c0 -f $f might also do what you want (and be better because it does not create a race condition between the two processes where data written could be ignored). I don't have access to a Linux system right now but do either of those do what you want? –  Michael Kjörling Jun 3 '13 at 8:47
    
This is useful and I just added such a feature to a programming language: a "tail stream" which can read a file normally from beginnnig to end, and then goes into "tail -f" mode at the end, and can also notice that the file was replaced with a shorter one or truncated, and follow that. You need this to be able to do things like process existing logs (catch up with a backlog) and then begin processing new entries. –  Kaz Nov 29 '13 at 6:26
add comment

2 Answers 2

up vote 4 down vote accepted

Here's one way to do it:

tail -f -n+0 /var/log/messages

There doesn't seem to be any difference between a +0 and a +1, so this would be equivalent:

tail -f -n+1 /var/log/messages
share|improve this answer
    
Thanks for the feedback, I've removed it as requested. –  slm Jun 3 '13 at 9:22
add comment

You could also invoke less using the F switch with +:

less +F -- $FILE

man less for details.

share|improve this answer
    
yep, I know about less, but it doesn't fit my purpose well - I'm using such operation in script and not doing it in interactive hand-mode –  om-nom-nom Jun 3 '13 at 9:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.