Sunday 15 March 2015

table - Iteration to rename column names -



table - Iteration to rename column names -

i have table , rename of headers, table this:

names rrdx21 rrdx23 rrdy78 rrdg00 rrdw90 ccv34 vvvbue [...] xxtur44 values 0 1 2 3 4 5 45 [...] 990 [...] values100 2 3 45 76 0 0 0 1000

one other hand have list the headers/column names want alter , new name want give, this:

rrdx3 sample2 rrdg00 sample23 [...]

as can imagine want maintain order of headers/columns. possible in awk, or simple script?

thanks in advance.

assume both files spaces separated, give line try: (i didn't test, should go)

awk 'nr==fnr{d[$1]=$2;next}fnr==1{for(i=1;i<=nf;i++)$i=d[$i]?d[$i]:$i}7' header.txt table.txt

table awk

No comments:

Post a Comment