I've got a file that would have lines similar to:
12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00 xx.00
I'm looking to basically do:
if [ current line > 1208 characters ]
delete characters at position 102-106
delete characters at position 1208-1214
copy modified line to new file
else
copy line as is to new file
so the new file would be:
12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
23456781 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
45678123 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00
all lines will start with an 8 digit key
we don't know what the characters we are deleting will be (so no pattern searches)
Right now I've been looking at doing a while read inputline loop and checking the character length of each line with the wc -m command. If -gt 1208 perform corrections and copy to new file.
I wasn't sure if there was an easier way to do this -- and I haven't actually been able to figure out the best way to make the corrections to each individual line.
Ok, just kidding. I don't know what happened the first time, but now it is no longer working. Is this maybe a problem with trying to switch from nawk to awk?
ok, it's the limitation of your version of awk.
lets try to fool it by setting the field separator to something would not appear in the data file - no guarantee that it would not like something else:
Alrighty-
so no matter what I tried it kept giving me the "can't have more than 199 fields" error. (Looks like the file has 202 - arg)
I think I figured out how to get rid of the extra characters (still need to verify that the invalid lines will have exactly the same data as the test file) with a sed command
now I just need to figure out how to either separate the invalid lines into a different file (to use sed)