[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tail bug when following non-existent files and skipping lines (tail
Re: Tail bug when following non-existent files and skipping lines (tail -F -n +2)
Sun, 9 Jun 2019 12:52:21 +0100
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 07/06/19 21:26, Jon Hart wrote:
> I have a file that does yet exist, but when it does finally exist I want to
> skip the first line and follow the remainder of the file. tail -F -n +2
> should do this, however it does not skip the first line -- it starts
> printing at the first line.
> In one shell, fire up tail on a file that does not yet exist and tell it to
> start printing at the second line:
> $ tail -F -n +2 /tmp/does_not_exist
> tail: cannot open '/tmp/does_not_exist' for reading: No such file or
> In another shell, write several lines to the non-existent file:
> $ echo -e "line1\nline2\nline3" > /tmp/does_not_exist
> Now see that tail printed out all three lines rather than skipping the
> tail: '/tmp/does_not_exist' has appeared; following new file
> tail/coreutils 8.28
> I don't see anything in the help that hints at what might be happening
> here. Smells like a bug. Can anyone else confirm?
Well really -n is ignored when files are replaced.
I.E. -F will just dump the entire file when it's been detected as replaced.
Consider subsequent replacements of the file.
You wouldn't want --lines=NUM to be honored on each replacement.
Now maybe we could treat --lines=+NUM specially, and honor on each replacment,
assuming it's skipping a header or something. Though that sounds too
special case to be done by the current options at least.