Replace number 7 with 8 of the last field of all the data.*.out files (every line of the file begins with a field "sriram") all the fields are seperated by | delimiter:
awk 'BEGIN {FS=OFS="|"} $1=="sriram" && $NF==7 {$NF=8} {print}' data.1.out
Note :
For the multiple data.[1-4].out files above , inorder to replace at a time, we can write as shown below:
for file in `ls data.*`; do echo $file; awk 'BEGIN {FS=OFS="|"} $1=="sriram" && $NF==7 {$NF=8}' $file > $file.tmp; mv $file.tmp $file; done
No comments:
Post a Comment