【发布时间】:2014-12-31 01:07:44
【问题描述】:
我正在尝试将一个文本文件拆分为两个不同的文件,文件看起来像这样:
//ABC12//burrito (line of text)
(line of text)
(line of text)
etc
//ABC12//taco (line of text)
(line of text)
(line of text)
etc
//ABC12//taco (line of text)
(line of text)
(line of text)
etc
//ABC12//burrito (line of text)
(line of text)
(line of text)
etc
所以我想将任何以 burrito 开头的行和所有后续行拆分为一个名为 burrito 的文件,直到读取其中包含 taco 的行,我认为最好的方法是:
for each line in $text;
if line contains burrito
outputfile=burrito
line>>$outputfile
elseif line contains taco
outputfile=taco
line>>$outputfile
else
line>>$outputfile
但我不确定,任何帮助将不胜感激。
【问题讨论】:
-
fedorqui,谢谢你清理我的帖子