我有file1
:
MSTRG.10807.1 0.494311896511595 MID 0.423993026403461 2.39379412548345 1.99703339651136
MSTRG.10884.1 0.365770947942799 EARLY 1.46416917664929 1.16816186543633 0.689075392478972
MSTRG.10958.1 0.52855355823638 MID 0.885493751836316 2.28463841550375 1.26867555157512
我使用命令sed 's/ /,/g' file1 > file2
并产生了file2
:
MSTRG.10807.1,,,0.494311896511595,,,MID,,,,0.423993026403461,,2.39379412548345,,,1.99703339651136
MSTRG.10884.1,,,0.365770947942799,,,EARLY,,1.46416917664929,,,1.16816186543633,,,0.689075392478972
MSTRG.10958.1,,,0.52855355823638,,,,MID,,,,0.885493751836316,,2.28463841550375,,,1.26867555157512
但我想要一个制表符分隔的文件。
答案1
使用tr
:
tr -s ' ' '\t' < file1 > file2
-s, --squeeze-repeats
将最后指定的 SET 中列出的每个重复字符序列替换为该字符的单个出现