I don't know why but this problem seems very difficult for a lot of people and they end up writing long complex multi line blocks of code to truncate a file and just keep the end of it. It is super simple with sed.
# only keep the last 100 lines of the log file sed -i /dev/shm/my_debug.log -e :a -e '$q;N;100,$D;ba'
No comments:
Post a Comment