Shell script to convert values on successive lines into consecutive ranges?
Hi all,
I have a series of input files formatted like this: Code:
RTREVF, KOG3266 = 111 Code:
RTREVF, KOG3266 = 1-111 Thanks, Kevin |
Code:
awk -vn=0 -F= '{printf("%s= %d-%d\n", $1, n+1, n+=$2);}' < input-file > output-file |
You can just use the print in this case too:
Code:
awk -F= '{print $1"+ "(n+1)"-"(n+=$2)}' infile |
Wow! Thanks guys! Both work great!
|
No concerns if the first record is "1" (or worse, "0") ?.
Corner cases are always a potential problem. |
That's a good thought that I hadn't considered but a previous step in the pipeline throws out any sequences that are less than 25 characters long.
Thanks! Kevin |
All times are GMT -5. The time now is 05:47 AM. |