我的文件中有三行这样的行
this is the first line blah1 blah2
this is the next line 0.101 0.202 0.303
this is the answer 0.404
期望
this is the first line 0.202 0.303 -0.404
可以使用 sed/awk/truncate (tr) 等在一两行内实现吗?
答案1
我确信这是否是你想要的,但我还是这么做吧。
您的文件
this is the first line blah1 blah2
this is the next line 0.101 0.202 0.303
this is the answer 0.404
将“blah1 blah2”替换为“0.202 0.303 -0.404”
sed -i 's/blah1 blah2/0.202 0.303 -0.404/' file
或这个
sed -i 's/blah1/0.202/' -i 's/blah2/0.303 -0.404/' file
文件内容
this is the first line 0.202 0.303 -0.404
this is the next line 0.101 0.202 0.303
this is the answer 0.404
如果这不是您想要的,请提供更多详细信息,我会调整我的答案。