Hi
I have a file & always I need to remove or delete last 2 lines from that file. So in a file if I have 10 lines then it should return me first 8 lines.
Can someone help me?
Hi
I have a file & always I need to remove or delete last 2 lines from that file. So in a file if I have 10 lines then it should return me first 8 lines.
Can someone help me?
sed '$d' file | sed '$d'
sed 'N;$!P;$!D;$d' myFile
Hi Vgersh
If I use the command you provided, it removes the last 2 records. But when this output is redirected to the other file, it shows the last 2 lines on the console & copies intended data to the file excluding last 2 records.
How to get rid of these last 2 appearing lines?
how exactly are you redirecting?
it works just fine here.
sed 'N;$!P;$!D;$d' myFile > myFile_new