Search code examples
linuxcommand-lineparallel-processinggnu-parallel

I want to execute multiple linux command lines in one .txt file(as parallel). I am using GNU parallel


I have a problem with reading multiple lines of Linux commands in one .txt file. And I want to use GNU parallel.

When I read the tutorial... I couldn't understand it properly.

I have one .txt file. and it has multiple command lines like this.

enter image description here

The only help I could get from the official tutorial was reading multiple .txt files.

How can I solve this?


Solution

  • Let us assume you have files like:

    /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam
    

    And you want to run:

    delly call -t DEL -n -q 15 -0 6_LEP-11_00186s.md.ir.br.bam.DEL.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam /data/jaesoon/DB/DB3/3_blood_4s_merged.bam
    delly call -t DUP -n -q 15 -0 6_LEP-11_00186s.md.ir.br.bam.DUP.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam /data/jaesoon/DB/DB3/3_blood_4s_merged.bam
    delly call -t INV -n -q 15 -0 6_LEP-11_00186s.md.ir.br.bam.INV.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam /data/jaesoon/DB/DB3/3_blood_4s_merged.bam
    delly call -t TRA -n -q 15 -0 6_LEP-11_00186s.md.ir.br.bam.TRA.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam /data/jaesoon/DB/DB3/3_blood_4s_merged.bam
    delly call -t INS -n -q 15 -0 6_LEP-11_00186s.md.ir.br.bam.INS.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta /data/jaesoon/DB/DB6/6_LEP-11_001E6s.md.ir.br.bam /data/jaesoon/DB/DB3/3_blood_4s_merged.bam
    

    Then you can do that by:

    parallel delly call -t {1} -n -q 15 -0 {2/}.{1}.bcf -g /data/jaesoon/DB/DB6/human_g1k.v37.fasta {2} /data/jaesoon/DB/DB3/3_blood_4s_merged.bam ::: DEL DUP INV TRA INS ::: /data/jaesoon/DB/DB6/*.bam
    

    May I suggest you read GNU Parallel 2018 (available at http://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html or download it at: https://doi.org/10.5281/zenodo.1146014) Read at least chapter 1+2. It should take you less than 20 minutes and your command line will love you for it.