我有一个文件,其中以下行出现了 4000 次,还有其他一些行。
:32A:151021JPY301,
我需要将第一次出现的值替换为 :32A:151021JPY5000
,然后将后续出现的值在最后增加 60。这意味着输出将是,
:32A:151021JPY5000,
:32A:151021JPY5060,
:32A:151021JPY5120,
.
.
.
.
答案1
找到了一个直接的解决方案。可以请你尝试一下吗...
cat test_file|sed 's/JPY301/JPY/g'|awk 'BEGIN {count=4940} count+=60 { print $1count}'
for example
$ cat test_file|sed 's/JPY301/JPY/g'|awk 'BEGIN {count=4940} count+=60 { print $1count}' :32A:151021JPY5000 :32A:151021JPY5060 :32A:151021JPY5120 :32A:151021JPY5180 :32A:151021JPY5240 :32A:151021JPY5300 :32A:151021JPY5360 :32A:151021JPY5420 :32A:151021JPY5480 :32A:151021JPY5540 :32A:151021JPY5600