Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Changing a string of blanks to a string of 0s in a specific column range in a data file.

rjsosiJul 12 2021 — edited Jul 12 2021

Hi,
We're using Redhat Linux 7.9 with bsh.
I want to go through a data file and replace all the fields between columns 10 and 20 that have blanks with 0s.

So if I have an example file of:
"#######################
#######################
#######################
######### ######
#######################
#######################
#######################
#######################"
I want the script to make it look like :
"#######################
#######################
#######################
#########000000000######
#######################
#######################"
#######################
#######################"

I've tried usign the followig:
awk '{val=substr($0,10,19);gsub(val," ","000000000")}1' scr1
But it only returns the original file. What did I miss?
Thanks!

Comments

Post Details

Added on Jul 12 2021
1 comment
92 views