bash - How could I put these lines in range format? -


i have text file 826,838 lines. text file looks this (sorry, couldn't image uploader work).

i'm using sed (sed -n '2p;$p') print second , last line can't figure out how put lines in range format.

current output:

     1    3008.00   7380.00  497724.00  3158482.00  497724.00   3158482.00 826838    4744.00   7409.00  480729.00  3207718.00  480729.00   3207718.00 

desired output:

1-826838  3008.00-4744.00  7380.00-7409.00  497724.00-480729.00  3158482.00-3207718.00  497724.00-480729.00  3158482.00-3207718.00 

thank help!

with single awk expression (will needed lines , make needed ranges):

awk 'nr==2{ split($0,a) }end{ for(i=1;i<=nf;i++) printf("%s\t",a[i]"-"$i); print "" }' file 

the output:

1-826838    3008.00-4744.00 7380.00-7409.00 497724.00-480729.00 3158482.00-3207718.00   497724.00-480729.00 3158482.00-3207718.00    

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -