gnu parallel for macs peak calling
not gnuparallel but nextflow. I don't know macs and what is 'first.bam' and 'second.bam' is not clear not me but I hope you'll get the idea.

The nextflow:

Channel.fromPath(params.bams).splitCsv(header: false,sep:'\t',strip:true).map{T-&gt;file(T[0])}.into{bams1;bams2}

boolean isControl(file) {
    return file.name.endsWith("_Input_sorted.bam_rem.bam") || file.name.endsWith("_IgG_sorted.bam_rem.bam ");
    }

bams1.filter{T-&gt;isControl(T)}.set{controls}
bams2.filter{T-&gt;!isControl(T)}.set{experiment}

process mac {
    maxForks 14
    tag "${bam1} vs ${bam2}"
    input:
        set bam1 , bam2  from experiment.combine(controls)
    output:
        file("output.peaks") into mac_peak
    script:
    """
    # check syntax please
    macs2 callpeak -t {bam1.toRealPath()}  -c ${bam2.toRealPath()} -g hs -n out-model -q 0.01 --outdir output.peaks
    """
    }     


invoke:

find /dir1/dir2 -type f -name "*.bam" &gt; input.list

nextflow run --bams input.list workflow.nf