1

How can I achieve this using awk/sed or any other scripting commands.

1) Read a file with many rows containing 26 digits in each line 2)Using shell scripting replace 07 with 08 only in 25th and 26th column of each row if 07 is found

Thankyou.

4

3 回答 3

2

awk

awk  'BEGIN{FS=""; OFS=""}{if ($25$26 == "07") {$25="0"; $26="8"}{print}}'
于 2013-06-05T20:18:26.613 回答
1

如果您确定文件中的每一行都有 26 位数字。(长度 26),您可以:

sed 's/07$/08/' file
于 2013-06-05T20:12:23.783 回答
1

这可能对您有用(GNU sed):

sed -r 's/^(.{24})07/\108/' file
于 2013-06-05T23:55:52.280 回答