I want to delete one or more specific line numbers from a file. How would I do this using sed?
1 Answer
To delete lines 2, 12-17 and line 57 from file data.txt
using sed
you could do something like this:
sed -e '2d;12,17d;57d' data.txt
to create a backup of the original file (with a .bak
extension) use -i.bak
with the command.
sed -i.bak -e '2d;12,17d;57d' data.txt