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!

Find and replace a decimal point in file at certain position

Status
Not open for further replies.

njdnjd

MIS
Jan 21, 2002
8
US
Hello fellow scripters: I am a beginner Unix scripter and would like to know if there are Unix commands available that would find and replace a deminal point in a .txt file AT A CERTAIN POSITION in the file. I have records of 250 character length and want to only target if the decimal point in at position 204 or greater. Are there commands that will accomplish this?

Thank you in advance for your time.
 
man awk

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
awk '{a=substr($0,1,203); b=substr($0,204);
sub(/\./, "?", b); print a b}' oldfile >newfile
 
Hello PHV, thank you for the sample script, I made one little change to it so it would capture all the "." after position 204 and that was to change sub to gsub.

I can't thank you enought for the help!

May you win the lottery, as I feel I have.
 
My apologies....futurelet, thank you for the script and see previous note.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top