【发布时间】:2014-04-26 07:13:21
【问题描述】:
我正在尝试从多行文件中提取文本。例如 我需要将所有文本从“Section 1.0”提取到“Section 3.0”
这可以在多行上。
我的代码可以运行,但看起来笨拙且缓慢。有一个更好的方法吗? 赛德? reg 表达式?
flag="false"
for line in ${textFile};
do
if [ "$line" == "Section 3.0" ]; then
flag="false"
fi
if [ "$flag" == "true" ]; then
temp_var+=$line
fi
if [ "$line" == "Section 1.0" ]; then
flag="true"
fi
done
【问题讨论】: