I haven't had much luck finding an answer to my problem, but maybe I'm not asking for it correctly.I have a process I startup like the following:nohup ping 127.0.0.1 > log.txt >2>&1 &Pretty simple command, send all the stdout to log.txt.  Only problem is that the command I'm running sends data every nth second to log.txt.  I'd like to output just one line to my log.txt file instead of appending it and running the risk of filling my drive up.Is there a way to just output one line to log.txt that continuously gets overwritten? 
Limit stdout from a continuously running process
bash;shell;text processing;output
Here is a quick and dirty solution to only keep the last line of output in the log file:ping localhost |   while IFS= read -r line; do     printf '%s\n' $line > log.txt;   doneBeware that you now probably have all kinds of race conditions when trying to access the file for reading. Locking the file from mutual access might help. For more information about locking this question on stackoverflow might be a good start: How do I synchronize (lock/unlock) access to a file in bash from multiple scripts?