paste pipeline 妙用 | sed -n 2~4p解

2020-08-05  本文已影响0人  kkkkkkang

paste 可以列合并文件,cat可以行合并文件

(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test.txt
this
is
a
test
o
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test1.txt
this
is
a
test
o
haha
aja
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ paste test.txt test1.txt > all_test.txt
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat all_test.txt
this    this
is      is
a       a
test    test
o       o
        haha
        aja
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test.txt  test1.txt > cat_all_test.txt
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat c
cat_all_test.txt    combined_reads.bam
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat cat_all_test.txt
this
is
a
test
o
this
is
a
test
o
haha
aja

在管道中paste还有妙用,合并N行显示

(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test.txt  | paste - - -
this    is      a
test    o
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test.txt  | paste - - - -
this    is      a       test
o
(base) yjk@DESKTOP-U8UULFU:~/test/bowtie2-2.4.1-linux-x86_64/example/reads$ cat test.txt  | paste - - - - -
this    is      a       test    o

还可以一行命令转fastq为fasta

cat file.txt | paste - - - - | cut -f1-2 |tr '@' '>' | tr '\t' '\n'

sed -n 2~4p 解读:-n只有符合条件的才输出;2~4p 从第二行开始,每四行输出一次

参考:https://www.jianshu.com/p/d10a85f21889

上一篇下一篇

猜你喜欢

热点阅读