Reputation: 749
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.
Upvotes: 1
Views: 207
Reputation: 58578
This might work for you (GNU sed):
sed -r 's/^(.{24})07/\108/' file
Upvotes: 1
Reputation: 23404
With awk
awk 'BEGIN{FS=""; OFS=""}{if ($25$26 == "07") {$25="0"; $26="8"}{print}}'
Upvotes: 2
Reputation: 195289
if you are sure each row in your file has 26 digits. (length 26), you could:
sed 's/07$/08/' file
Upvotes: 1