I need to trim the top 5 rows and the last row of my csv using a Unix
command that I can run in a shell script.
I currently have head -n -1 file.csv | tail -n +6 file.csv > newfile.csv this outputs a new csv starting from row 6 which is what I need however the first part of the command fails as illegal line count -- -1
I first done
tail -n +6 file.csvto remove the first 5 rows.Then to remove the last row of the
csvi had to flip thecsvso the last row was at the top I done this by using thetail -rcommand.I then used the same command from the start to remove the now first row
tail -n +2and finally flipped thecsvback using thetail -rcommand.tail -n +11 input.csv | tail -r | tail -n +2 | tail -r > output.csv