remove field from tab seperated file using awk -


i trying clean-up tab-delineated files , thought awk below remove field 18 otherinfo file. tried cut , can not seem desired output. thank :).

file

chr start   end ref alt func.refgene    gene.refgene    genedetail.refgene  exonicfunc.refgene  aachange.refgene    popfreqmax  clinsig clndbn  clnacc  clndsdb clndsdbid   common  otherinfo chr1    949654  949654    g   exonic  isg15   .   synonymous snv  isg15:nm_005101:exon2:c.294a>g:p.v98v   0.96    .   .   .   .   .   .   1   3825.28 624 chr1    949654  .     g   3825.28 pass    af=1;ao=621;dp=624;fao=399;fdp=399;fr=.;fro=0;fsaf=225;fsar=174;fsrf=0;fsrr=0;fwdb=0.00425236;fxx=0.00249994;hrun=1;len=1;mlld=97.922;oalt=g;oid=.;omapalt=g;opos=949654;oref=a;pb=0.5;pbp=1;qd=38.3487;rbi=0.0367904;refb=0.0353003;revb=-0.0365438;ro=2;saf=335;sar=286;srf=0;srr=2;ssen=0;ssep=0;sssb=0.00332809;stb=0.5;stbp=1;type=snp;varb=-3.42335e-05;ann=isg15 gt:gq:dp:fdp:ro:fro:ao:fao:af:sar:saf:srf:srr:fsar:fsaf:fsrf:fsrr   1/1:171:624:399:2:0:621:399:1:286:335:0:2:174:225:0:0 399 reads 

desired output

chr start   end ref alt func.refgene    gene.refgene    genedetail.refgene  exonicfunc.refgene  aachange.refgene    popfreqmax  clinsig clndbn  clnacc  clndsdb clndsdbid   common chr1    949654  949654    g   exonic  isg15   0   synonymous snv  isg15:nm_005101:exon2:c.294a>g:p.v98v   0.96    .   .   .   .   .   . 

awk (runs doesn't remove field 18)

awk '{ $18=""; print }' file1 

cut (removes field except 18)

cut -f18 file1 

by default, awk uses blanks delimiters. therefore, have specify use tabs delimiters in output (ofs):

awk 'begin{fs=ofs="\t"}{$18=""; gsub(/\t\t/,"\t")}1' file1 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -