Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

editing text file in ksh script question

Status
Not open for further replies.

genod

Technical User
Feb 5, 2001
2
US
I have a text file that looks similar to this...

.FMAP6 0201200112Z
101 0.45 0.00 0.34 1.24
102 0.00 2.34 3.21 0.00
103 0.00 0.00 0.45 0.00

.
.
etc
.
.

I'm trying to figure out how to change all of the values in the 4 columms to 0.00 while preserving the format. The number of rows changes on occasion. Everything else needs to be preserved. The file should end up looking like this...


.FMAP6 0201200112Z
101 0.00 0.00 0.00 0.00
102 0.00 0.00 0.00 0.00
103 0.00 0.00 0.00 0.00

.
.
etc
.
.

Thanks for any help

 
Try: -
sed -e &quot;s/[0-9]\.[0-9][0-9]/0\.00/g&quot; < datafile > newfile

(Assumes data is of the format n.nn)

Ged Jones

Top man
 
thanks for the help. That worked!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top