I have some input and output from various widgets that I am trying to get to play nicely together. Basically I would like to stay out of excel and be able to automate the entire process. I have read some posts here about how to use awk, nawk, etc, to do similar operations, but nothing quite the same.
One thing I need to do is to add a leading column with "index" as the value for the first row, and then sequentially number the remaining rows. I know how to number all rows in sed, but not how to skip the first row. I also need to remove column three at some later point, etc.
I think if I can get these two operations working, I can adapt for the rest.
Thanks a bunch for any suggestions, I think these operations are simple, but many things are simple once you know how.
Welcome to the forum. In the future, please provide some sample of the data being worked with (feel free to obfuscate sensitive info, so long as the format isn't affected). With nothing to go on, here's my shot in the dark (i've assumed the data is a comma-delimited file):
awk 'NR==1{print "index,"$0} NR>1{print NR-1","$0}' data
Well I have it working more or less, thanks to everyone for the help. This is the script at the moment, warning, there should be an ugly flag on this somewhere.
A friend of mine said you should never be too embarrassed about something that actually works, but I am not so sure about this one.
After several attempts to put the script in code tags, I have attached it. The zip contains the script, the output from the first bin called by the script, and the output from the second bin, in case anyone wants to hot wire this and view the ugliness. It also contains the two output files, which are formatted as needed.
I am interested in learning, so any comments as to better methods of getting from here to there would be appreciated.