bash - Split column and use first array to headerin awk -


i have file looks this:

a=10 b=8 c=12 a=15 b=12 c=5 a=6 b=4 c=9 a=8 b=8 c=9 

columns more. split file using awk , use letter before "=" header:

a b c 10 8 12 15 12 5 6 4 9 8 8 9 

i like:

awk '{split($0,arr0,"="); print arr0[2]}' infile 

but still not know how use arr0[1] header.

thank ideas.

using awk can this:

awk -f '[= ]' 'function prnt(start) {    (i=start; i<=nf; i+=2)       printf "%s%s", (i==start?"":ofs), $i    print "" } nr==1 {    prnt(1) } {    prnt(2) }' file  b c 10 8 12 15 12 5 6 4 9 8 8 9 

and tabular formatted output use:

awk -f '[= ]' 'function prnt(start) {    (i=start; i<=nf; i+=2)       printf "%s%s", (i==start?"":ofs), $i    print "" } nr==1 {    prnt(1) } {    prnt(2) }' file | column -t    b   c 10  8   12 15  12  5 6   4   9 8   8   9 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -