小编boc*_*767的帖子

在第一列中加入具有相同值的行

我有一个带有三列的制表符分隔文件(摘录):

AC147602.5_FG004    IPR000146   Fructose-1,6-bisphosphatase class 1/Sedoheputulose-1,7-bisphosphatase
AC147602.5_FG004    IPR023079   Sedoheptulose-1,7-bisphosphatase
AC148152.3_FG001    IPR002110   Ankyrin repeat
AC148152.3_FG001    IPR026961   PGG domain
Run Code Online (Sandbox Code Playgroud)

我想用bash来解决这个问题:

AC147602.5_FG004 IPR000146 Fructose-1,6-bisphosphatase class 1/Sedoheputulose-1,7-bisphosphatase IPR023079 Sedoheptulose-1,7-bisphosphatase
AC148152.3_FG001 IPR023079 Sedoheptulose-1,7-bisphosphatase IPR002110   Ankyrin repeat IPR026961    PGG domain
Run Code Online (Sandbox Code Playgroud)

因此,如果第一列中的ID在多行中相同,则应为每个ID生成一行,并连接所有其他行.在示例中,它将提供两行文件.

bash awk

5
推荐指数
1
解决办法
3684
查看次数

像 SAS 一样加入 bash

我想使用公共列在bash中加入两个文件。我想保留两个文件中所有可配对和不可配对的行。不幸的是,使用join我只能保存一个文件中不可配对的字段,例如。join -1 1 -2 2 -a1 -t" "
我还想保留两个文件中重复条目(在连接列中)的所有配对。即如果 file1 是
x id1 ab
x id1 cd
x id1 df
x id2 cx
x id3 fv

第二个文件是

id1 df cf
id1 ds dg
id2 cv df
id2 as ds
id3 cf cg

生成的文件应该是:

x id1 ab df cf
x id1 ab ds dg
x id1 cd df cf
x id1 cd ds dg
x id1 df df cf
x id1 df ds dg
x …

bash join sas

3
推荐指数
1
解决办法
1671
查看次数

标签 统计

bash ×2

awk ×1

join ×1

sas ×1