我想要将两个文件一起添加,其中一个只有1列,另一个只有10个,我想在另一个文件的乞讨中添加一个列!他们没有任何类似的专栏!
我尝试了join
命令,但需要一个类似的列(据我所知)然后我尝试了cat
命令,它可以工作,但它不会将它保存为第一列! / p>
所以文件格式如下:
File1中:
probeset_id
AX-76431849
AX-76431844
AX-76431845
文件2:
submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_258
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
我正在尝试输出:
probeset_id submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_258
AX-76431849 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431844 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431845 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
当我使用cat
命令时,我得到了这个:
probeset_id
AX-76431849
AX-76431844
AX-76431845
submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_258
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
"0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
答案 0 :(得分:5)
使用paste
:
$ paste -d' ' file1.txt file2.txt
probeset_id submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_258
AX-76431849 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431844 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431845 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
答案 1 :(得分:2)
$ paste -d ' ' file1.txt file2.txt
probeset_id submitted_id chr snp_pos alleleA alleleB 562_201 562_202 562_203 562_204 562_205 562_206 562_207 562_208 562_209 562_258
AX-76431849 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431844 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
AX-76431845 "0" "1" "0" "0" "2" "1" "1" "0" "1" "1"
答案 2 :(得分:2)
您可以使用粘贴
paste -d " " file1.txt file2.txt > result.txt
-d 标志指定字段之间所需的分隔符。默认是一个标签。