linux - Remove columns from file bash tools -
i have large file 200,000 columns , 5000 rows. here short example of file, columns 1 , 5 duplicated.
abf bgj csd daa abf efg ... 0 1 2 1 0 1.1 2 0.1 1.2 0.3 2 1 ...
here example of result need. column 5 in original file has been deleted.
abf bgj csd daa efg ... 0 1 2 1 1.1 2 0.1 1.2 0.3 1 ...
some of columns duplicated several times. need remove duplicates data (keeping first instance) using bash tools. can´t sort data because need keep order.
$ cat tst.awk nr==1 { (i=1;i<=nf;i++) { if (!seen[$i]++) { f[++nf]=i } } } { (i=1;i<=nf;i++) { printf "%s%s", $(f[i]), (i<nf?ofs:ors) } } $ awk -f tst.awk file | column -t abf bgj csd daa efg 0 1 2 1 1.1 2 0.1 1.2 0.3 1
Comments
Post a Comment