我在Unix中有一个如下(test.txt
)的文件:
20130912-02:29:03 BT_TBL CISCUST BT_TBL_CISCUST_003015.dat
20130912-05:00:04 BT_TBL TMVLP BT_TBL_TMVLP_001026.dat
20130912-08:26:20 D_SNODE CPR8S D_SNODE_CPR8S_001772.dat
20130912-12:15:37 BT_PRA EWSDCAI BT_PRA_EWSDCAI_193228.dat
20130912-12:15:03 AMSD TTFILE AMSD_TTFILE_285130.dat
20130912-12:10:02 SIN2TTFILE SIN2_TTFILE_131635.dat
20130912-12:15:16 BT_ONEI NOAS_AM BT_ONEI_NOAS_AM_032902.dat
我需要像这样的固定长度的列。它们之间应使用制表符分隔:
20130912-02:29:03 BT_TBL CISCUST BT_TBL_CISCUST_003015.dat
20130912-02:30:05 BT_TBL CISTERM BT_TBL_CISTERM_003034.dat
20130912-05:00:04 BT_TBL CTVLP BT_TBL_CTVLP_001005.dat
20130912-05:00:04 BT_TBL TMVLP BT_TBL_TMVLP_001026.dat
20130912-08:26:20 D_SNODE CPR8S D_SNODE_CPR8S_001772.dat
20130912-08:20:07 D_SNODE CPR9S D_SNODE_CPR9S_001692.dat
20130912-08:20:08 D_SNODE SUB9S D_SNODE_SUB9S_001691.dat
20130912-12:15:37 BT_PRA EWSDCAI BT_PRA_EWSDCAI_193228.dat
20130912-12:15:03 AMSD TTFILE AMSD_TTFILE_285130.dat
20130912-12:20:02 DLLS TTFILE DLLS_TTFILE_137361.dat
20130912-12:20:02 LOGS TTFILE LOGS_TTFILE_150352.dat
20130912-12:10:02 SIN2 TTFILE SIN2_TTFILE_131635.dat
20130912-12:15:16 BT_ONEI NOAS_AM BT_ONEI_NOAS_AM_032902.dat
20130912-12:10:25 BT_ONEI NOAS_FF BT_ONEI_NOAS_FF_030531.dat
20130912-12:21:01 BT_IN AMSSC11 BT_IN_AMSSC11_565012.dat
20130912-12:22:01 BT_IN AMSSC12 BT_IN_AMSSC12_571777.dat
20130912-12:21:32 BT_IN FFTSC11 BT_IN_FFTSC11_580199.dat
20130912-12:22:31 BT_IN FFTSC12 BT_IN_FFTSC12_576488.dat
20130912-12:22:02 AMSD VP_IN AMSD_VP_IN_770412.dat
20130912-12:24:01 DLLS VP_IN DLLS_VP_IN_412252.dat
20130912-12:23:02 LOGS VP_IN LOGS_VP_IN_440553.dat
20130912-12:20:03 SIN2 VP_IN SIN2_VP_IN_395060.dat
我怎样才能做到这一点?
该文件看起来像是脚本的输出。也许修复生成它的脚本比修复输出本身更容易?
—
Vladimir Tsuverkalov 2013年
下次,请通过查看问题的预览来注意格式化。谢谢。
—
slhck 2013年
那
—
mveroone 2013年
sed -i 's/ */\t/' file
呢
为什么用Microsoft-Excel标记问题?
—
杰里(Jerry)