#!/bin/ksh93 # set to ksh93 so we can use substring
cat "file" |
while IFS=\n read I # read the next record into I
do # do not parse out blanks, tabs in the record by setting IFS to newline char only
D1=${I:27:1} # isolate byte 27 into D1
if [[ "$D1" = " " ]] # if byte 27 = a blank
then
${I:27:1}="-" # change byte 27 to a dash "-" <-- ### WARNING, this syntax is invalid ###
else
: # no change to byte 27
fi
print "$I" # write out record
done
A question on the above code:
- is there a simple way (using substring) to modify byte 27 using the above example ?
FWIW, I wasn't able to come up with any syntax that would allow me to substring the desired change back into the record. I had to use other techniques to accomplish the same thing..... but was hoping the experts here might see something simple, that no doubt I missed. Thx for any help.