I have try to use sed command for delete particular line from file but it seems not working properly in my system (CentOS release 6.3 (Final).
my file1.txt contain following data
line1
line2
line3
line4
line5
Now i try below command to delete 3rd line from the file.
$ sed '3d' file1.txt
And output of above command is
line1
line2
line4
line5
But when i check original file then it seems nothing deleted. 3rd line is there.
So any one have idea why sed not working?
Make it in-line sed:
sed -i.bak '3d' file1.txt
To delete particular lines from a file using sed without creating a backup:
sed -i '' -e '3,6d' file1.txt
The command above will remove lines 3 up to and including 6 from file1.txt, without creating a backup