Use this command if you want to keep only a certain number of the most recent lines in the file without using an additional file.
1 2 3 |
FILE=yourFileName; LINES_QTY=`wc -l ${FILE} | awk '{print $1-200}'`; if [ $LINES_QTY \> 0 ]; then sed -i 1,${LINES_QTY}d ${FILE}; fi |
Replace:
* yourFileName – your filename
* 200 – the number of lines you want to keep