Awk
用 TAB 替換空格,最後一列除外
我有一個看起來像這樣的文件。除了以 ID 開頭的最後一列之外,如何用 TAB 替換每個空格?
chr1 13513 14763 Medtr1g004950 . + JCVI gene . ID=Medtr1g004950;Note=hypothetical protein chr1 15282 16532 Medtr1g004960 . + JCVI gene . ID=Medtr1g004960;Note=hypothetical protein chr1 30972 32222 Medtr1g004980 . + JCVI gene . ID=Medtr1g004980;Note=hypothetical protein
任君挑選:
$ sed 's/ /\t/g; s/\t/ /10' file chr1 13513 14763 Medtr1g004950 . + JCVI gene . ID=Medtr1g004950;Note=hypothetical protein chr1 15282 16532 Medtr1g004960 . + JCVI gene . ID=Medtr1g004960;Note=hypothetical protein chr1 30972 32222 Medtr1g004980 . + JCVI gene . ID=Medtr1g004980;Note=hypothetical protein $ sed 's/ /\t/g; s/\t\([^\t]*\)$/ \1/' file chr1 13513 14763 Medtr1g004950 . + JCVI gene . ID=Medtr1g004950;Note=hypothetical protein chr1 15282 16532 Medtr1g004960 . + JCVI gene . ID=Medtr1g004960;Note=hypothetical protein chr1 30972 32222 Medtr1g004980 . + JCVI gene . ID=Medtr1g004980;Note=hypothetical protein