Reputation: 17
I have a file which looks a bit like
column1 column2 column3
1 45n8 005
2 125n05 007
3 002n012 009
How can I use awk to replace the 'n' in column2 with a '.' where the output will look like this:
column1 column2 column3
1 45.8 005
2 125.05 007
3 002.012 009
my attempt at this is awk 'BEGIN{OFS=",";}{gsub("n",".",$2);print}' file1.txt>file2.txt
and its giving me a 'command not found' error
Upvotes: 0
Views: 769
Reputation: 195289
you don't want to replace all n
in a row, but only the col2, so you could:
awk 'NR>1{sub(/n/,".",$2)}7' file
If you want the output format looks better:
awk 'NR>1{sub(/n/,".",$2)}7' file|column -t
Upvotes: 1