I’m trying to knock out a really quick and dirty bash script which will perform a very simple task, but I’m not familiar enough with sed or awk syntax to manage it.
Here’s what I need the script to do:
script will search for all files of the type .sps in the folder it’s located and perform the following:
Read in a line and modify it as follows
SAMPLE LINE BEFORE EDIT
216992841 22481A2 8.0 303429.4 2883339.0 201 530 4
SAMPLE LINE AFTER EDIT
216992841 22481A2 8.0 0 303429.4 2883339.0 0.0201 530 4
Go through each line in each .sps file and perform the above modification (inserting the 0’s and 0.0’s in the appropriate places)
Ideally, I would like it to just edit the existing .sps files and save the “new” one with the same file name.
Please note that the first 0 will be in its own column, but the 0.0 needs to be prepended to that other value near the end. Also note that ALL lines follow this same basic pattern as given in the sample. The only exception is the last few values “201 530 4” might be a single value like “199345592.” The spaces are essentially just 0’s in the “201 530 4” sample given.
This is something I can do in vi in a few seconds, of course, but I have to do it so often it would be nice to just have a script do it for me.
So, all you awk/sed masters, can you help me out?