Tuesday, July 22, 2014

How to remove specific lines from file in Unix

To remove line 126 from file use sed command:

sed -i.bak -e '126d' file.txt

Original file.txt will be saved in a bak copy.

To remove line 126 and lines 136-140:

sed -i.bak -e '126d; 136,140d' file.txt

No comments:

Post a Comment