Computing.Net > Forums > Programming > replacing a number with a string

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

replacing a number with a string

Reply to Message Icon

Name: sweta
Date: March 12, 2009 at 02:54:21 Pacific
OS: fedora core 9
Subcategory: General
Comment:

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??



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 12, 2009 at 07:14:01 Pacific
Reply:

#!/bin/bash

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


0

Response Number 2
Name: sweta
Date: March 13, 2009 at 04:02:51 Pacific
Reply:

Thanks....:-)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


batch file to copy & incr... Not trusted sites



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: replacing a number with a string

Batch = Store 1 number at a time www.computing.net/answers/programming/batch-store-1-number-at-a-time-/15300.html

Readout number with batchfile www.computing.net/answers/programming/readout-number-with-batchfile/16222.html

Replace blank spaces with ; in a tx www.computing.net/answers/programming/replace-blank-spaces-with-in-a-tx/13192.html