【发布时间】:2015-05-27 11:35:11
【问题描述】:
我有一个这样的文件:
>ref
AAAAAAA
>seq1
BBBBBBB
>seq2
CCCCCCC
>seq3
DDDDDD
我想得到:
>ref
AAAAAAA
>seq1
BBBBBBB
>ref
AAAAAAA
>seq2
CCCCCCC
>ref
AAAAAAA
>seq3
DDDDDD
我正在考虑在 bash 中使用这个命令:
ref=$(head -n 2 file)
awk '/>/{print "'"$ref"'"}1' file
这是我得到的:
awk: non-terminated string >ref... at source line 2
context is
/>/{print ">ref >>>
<<<
知道发生了什么吗? :) 非常感谢!
编辑:我想将此管道用于所有以不同 ref 开头的文件:ref1 用于 file1,ref2 用于 file2,...因此考虑使用 head将每个ref 存储在一个变量中以将其用于每个文件:)
【问题讨论】: