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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Substitution with Awk or Sed

Status
Not open for further replies.

qusan

Technical User
Jun 8, 2004
2
US
I have a file with multiple records:
0287C04200302201511330000000133986589898989 160180 00000001xxxx_xxxx_020_xxxxx.dat

I need to change characters 35-42 to zeros. Is there a substitution command to do this with awk or sed?
 
awk solution (untested)

awk '{print substr($0,1,34) "00000000" substr($0,43)}' infile > outfile

Somebody will be along with the sed solution soon

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top