感觉你的需求只是简单的把"<<"作为查询条件,那么就直接把这一行信息挑出来了。cat a.txt | grep "<<" > b.txt你试试看吧
try:
sed -n '/keywords/p' a.txt >new.txt