Reputation: 2519
I have a flat file with N columns.
The Nth column contains word 'abc' several time at different rows.
How can I replace this word 'abc' with 'def'.
The output file should contain the same data till the 'N-1' columns, only in the Nth column the multiple occurences of the word 'abc' should be changed to 'def'.
Please advise on how to acheive this.
Regards, Srihari
Upvotes: 1
Views: 73
Reputation: 77155
With awk
:
awk 'BEGIN{FS=OFS=":"}{$NF=($NF~/abc/)?"def":$NF}1' your_file
Upvotes: 1