美文网首页
paste pipeline 妙用 | sed -n 2~4p解

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

作者: kkkkkkang | 来源:发表于2020-08-05 10:54 被阅读0次

    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

    相关文章

      网友评论

          本文标题:paste pipeline 妙用 | sed -n 2~4p解

          本文链接:https://www.haomeiwen.com/subject/hlajrktx.html