shell delete with line number

If you want to delete lines 5 through 10 and 12:

sed -e '5,10d;12d' file

This will print the results to the screen. If you want to save the results to the same file:

sed -i.bak -e '5,10d;12d' file

This will back the file up to file.bak, and delete the given lines.

posted @ 2019-01-16 16:00  kakaisgood  阅读(193)  评论(0编辑  收藏  举报