假设有一个file.txt,其中某处介于"从这里开始" 行。所以我的要求是将整行文本从此行复制到使用 shell脚本在另一个文件中使用EOF。
答案 0 :(得分:3)
#!/bin/bash
write_=false
while read line || [[ -n "$line" ]]; do
if [ $write_ == true ]; then
echo $line
elif [ "$line" == "Start from here" ]; then
write_=true
fi
done < "file.txt" > "other_file.txt"
files.txt
foo foo foo
bar bar bar
Start from here
This should be
in the file
and not anything else