我想复制从word(搜索的字/行)开始到文件末尾的文件内容。
实施例: 文件1:
this is a sample text for file1 in PA
this is a sample text for file1 in CA
this is a sample text for file1 in CT
this is a sample text for file1 in IL
this is a sample text for file1 in MI
end of the file.
我想将内容从具有“CT”的行复制到file2,直到文件末尾。 输出: file2的
this is a sample text for file1 in CT
this is a sample text for file1 in IL
this is a sample text for file1 in MI
end of the file.
答案 0 :(得分:3)
您可以使用sed
:
sed -n '/searchtext/,$p' file1 > file2
或awk
:
awk '/searchtext/ {flag=1} flag;' file1 > file2
答案 1 :(得分:1)
awk '{if($0~/CT/)p=1;if(p)print}' your_file