replacing a number with a string

March 12, 2009 at 02:54:21
Specs: fedora core 9
hi,
I want to replace a number with a string in a specific column of a text file.
Eg:
abc def 1
agf gdh 1
ytr ate 0
.......
...
i would like to replace '1' in column 3 with 'yes'.

Is it possible using awk command??


See More: replacing a number with a string

Report •


#1
March 12, 2009 at 07:14:01
#!/bin/bash

awk ' {
   if($3 == 1)
      $3="yes"
   print $0
} ' datafile.txt


Report •

#2
March 13, 2009 at 04:02:51
Thanks....:-)

Report •

Related Solutions


Ask Question