I have a large csv file that I need to reduce to the last 1000 lines through a cron job every day.
Can anyone suggest how to accomplish this?
What I have so far are two commands but do not know how to combine them
For deleting lines from the beggining of the file the command is
ed -s file.csv <<< $'1,123d\nwq'
where 123 is the number of lines needed to delete from the beginning of the file
For reading the number of lines in the file the command is
wc -l file.csv
I would need to subtract 1000 from this and pass the result to the first command Is there any way to combine the result of wc command in the ed command?
Thank you in advance