$cat datafile BlankLine a Line start with "Cn:" BlankLine
Want to direct these lines to a new file and remove it from current file. datafile contains plenty of lines.
答案 0 :(得分:1)
sed
可能会完成工作,
$ sed -e '/BlankLine/,/BlankLine/w newfile' -i -e '/BlankLine/,/BlankLine/d' datafile
简要说明,
'/BlankLine/,/BlankLine/w newfile'
:搜索从'BlankLine'到另一'BlankLine'的行,并将其写入 newfile 。-i -e '/BlankLine/,/BlankLine/d'
:删除在数据文件中写入的行。