Hi. I'm writing a Korn Shell script, and it does several things. However, I am unable to make it do one thing. I want it to read in a fixed-width file, and output a fixed width file. I want it to read each record of the input file, and determine whether or not bytes 10-20 are blank. If they are, I want a 'N' written to the output file. I they are populated, I want a 'P' written t the output file. So, here's an example:
Input File:
1234567890 MinnesotaMN5555555
0987654321 Nebraska NE6666666
1029384756MinneapolisMinnesotaMN5555555
5674839201Portland Oregon OR1111111
8943027615 NomeAlaska AK2222222
8273645019 Iowa IA4444444
In these cases, I want the output file to read:
1234567890NMinnesotaMN5555555
0987654321NNebraska NE6666666
1029384756PMinnesotaMN5555555
5674839201POregon OR1111111
8943027615PAlaska AK2222222
8273645019NIowaIA4444444
Where bytes 10-20 are replaced by either an 'N' or a 'P'.
Does that make sense to anyone? My logic is solid, I think, I just need to translate it to code. My logic:
While read cur_rec
if (bytes 10-20 ARE populated)
write out cur_rec, insert a 'P'
else
write out cur_rec, insert an 'N'
Anyway, if someone could please help me out here, I would greatly appreciate it. Thanks!
Input File:
1234567890 MinnesotaMN5555555
0987654321 Nebraska NE6666666
1029384756MinneapolisMinnesotaMN5555555
5674839201Portland Oregon OR1111111
8943027615 NomeAlaska AK2222222
8273645019 Iowa IA4444444
In these cases, I want the output file to read:
1234567890NMinnesotaMN5555555
0987654321NNebraska NE6666666
1029384756PMinnesotaMN5555555
5674839201POregon OR1111111
8943027615PAlaska AK2222222
8273645019NIowaIA4444444
Where bytes 10-20 are replaced by either an 'N' or a 'P'.
Does that make sense to anyone? My logic is solid, I think, I just need to translate it to code. My logic:
While read cur_rec
if (bytes 10-20 ARE populated)
write out cur_rec, insert a 'P'
else
write out cur_rec, insert an 'N'
Anyway, if someone could please help me out here, I would greatly appreciate it. Thanks!