I need to select certain lines from the log file and also save them to a text file. I tried the following but none of them are working as expected. The file "todel.txt" shows 0 bytes.
tail -f general.log | grep Some_word > >(tee -a todel.txt)
tail -f general.log | grep Some_word ; tee todel.txt
tail -f general.log | grep Some_word | tee -a todel.txt
tail -f
will give you last 10 lines of input and whatever is written there unless the file is removed and recreated, in which case it quits. GNUtail
has the--retry
option which will wait until the file is recreated (although I think this option is non-POSIX). – peterph Nov 25 '13 at 23:15