【发布时间】:2016-02-16 19:39:40
【问题描述】:
假设有一些包含此类数据的 file.txt:
@@comp1,1111,1111,pass
@@comp2,2222,2222,pass
.
.
@@comp34,error,,,fail
.
.
@@comp65,6565,6565,pass
然后我必须插入遗漏的值,它们是:
expected=3434,observed=0000
在“失败”之前的正确字段中。我还有$line_number应该插入它:
@@comp34,error,3434,0000,fail
我尝试了不同的解决方案,但它们都不起作用。 例如:
new1=`awk -n=$line_number -F, '{print $3}' text.txt` | sed 's/$new1/$expected' > text.txt
new2=`awk -n=$line_number -F, '{print $4}' text.txt` | sed 's/$new2/$observed' > text.txt
【问题讨论】:
-
你能添加你的预期输出吗?