使用sed从文本文件中删除特定的行号?


Answers:


63

data.txt使用文件删除第2、12-17和57行,sed您可以执行以下操作:

 sed -e '2d;12,17d;57d' data.txt

创建与命令一起.bak使用的原始文件(带有扩展名)的备份-i.bak

 sed -i.bak -e '2d;12,17d;57d' data.txt
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.