awk - Find letters in columns which are same like in first column and print it -
i have table values , have find match: first column others , print match.
input:
a:0 a:0.7541 a:0.7396 a:0.7694 a:0 0:0 0:0 0:0 c:0 c:0.8408 c:0.8459 c:0.7939 g:0 g:0.3415 g:0.3290 g:0.4228 g:0 g:0.0343 g:0.0378 t:8.237e06,g:0.02437 c:0 c:0.3895 c:0.3837 a:8.255e06,t:8.255e06,c:0.3623
output:
a:0 0.7541 0.7396 0.7694 a:0 0 0 0 c:0 0.8408 0.8459 0.7939 g:0 0.3415 0.3290 0.4228 g:0 0.0343 0.0378 0.02437 c:0 0.3895 0.3837 0.3623
for last row.. if c in second column, print number after matching letter c in case, same columns, there more values separated ",". print number contain match letter c in case row. wrote :
awk '{split ($1,a,":");split ($2,b,":"); split($3,c,":"); split($4,d,":"); if(a[1]=b[1] && a[1]=c[1] && a[1]==d[1]) print $0}' /home/fil/desktop/uprava.txt
awk
rescue!
$ awk '{key=substr($1,1,2); n=split($nf,last,","); if(n>1) for(i=1;i<=n;i++) if(last[i]~key) {$nf=last[i]; break} for(i=2;i<=nf;i++) sub(key,"",$i); print}' file | column -t a:0 0.7541 0.7396 0.7694 a:0 0:0 0:0 0:0 c:0 0.8408 0.8459 0.7939 g:0 0.3415 0.3290 0.4228 g:0 0.0343 0.0378 0.02437 c:0 0.3895 0.3837 0.3623
Comments
Post a Comment