What are you trying to accomplish with the tail -f command?
And then your grep "third"?
Are you simply trying to narrow your search to the last ten lines (default of the tail command), and then find the line with the word "third"? If so, try without the -f on the tail command.
By the way, I am not convinced that your example works fine when you think it does. The -f on the tail command would appear to keep the process running awaiting additional input.
It was just an example to illustrate a real-world problem that I have.
Basically I need to tail a syslog file, grep for a certain pattern then display a certain field from the matched line. What I wanted to say with my example is that the "cut" after the "grep" is not producing anything, even though it should (as far as I can tell). It does not matter if I tail a syslog file or a testfile created by me, it should still work.
And sure, tail -f waits for more input but that does not matter, by default it should still list the last 10 lines or so from the file, which is plenty of input for my grep and cut.
Nice, that works fine Thanks. One more quick question: how would I print everything from the 7th field to the end of the line , in awk ? Something like cut's -f 7- .
Trying this out on several files, because the -f keeps the process open, appears to therefore not allow any additional commands after the first pipe.
tail -f file | grep val1 >will work
tail -f file | grep val1 | grep val2 >will not work
but,
tail file | grep val1 | grep val2 > will work