title: Change text in argument for xargs (or GNU Parallel)
body: <p>I have a program that I can run in two ways: single-end or paired-end mode. Here's the syntax:</p>
  
  <pre><code>program &lt;output-directory-name&gt; &lt;input1&gt; [input2]
  </code></pre>
  
  <p>Where the output directory and at least one input is required. If I wanted to run this on three files, say, sample A, B, and C, I would use something like find with xargs or parallel:</p>
  
  <pre><code>user@host:~/single$ ls
  sampleA.txt  sampleB.txt  sampleC.txt
  
  user@host:~/single$ find . -name "sample*" | xargs -i echo program {}-out {}
  program ./sampleA.txt-out ./sampleA.txt
  program ./sampleB.txt-out ./sampleB.txt
  program ./sampleC.txt-out ./sampleC.txt
  
  user@host:~/single$ find . -name "sample*" | parallel --dry-run program {}-out {}
  program ./sampleA.txt-out ./sampleA.txt
  program ./sampleB.txt-out ./sampleB.txt
  program ./sampleC.txt-out ./sampleC.txt
  </code></pre>
  
  <p>But when I want to run the program in "paired-end" mode, I need to give it two inputs. These are related files, but they can't simply be concatenated - you have to run the program with both as inputs. Files are named sensibly, e.g., sampleA_1.txt and sampleA_2.txt. </p>
  
  <p>I want to be able to create this easily on the command line with something like xargs (or preferably parallel):</p>
  
  <pre><code>user@host:~/paired$ ls
  sampleA_1.txt  sampleB_1.txt  sampleC_1.txt
  sampleA_2.txt  sampleB_2.txt  sampleC_2.txt
  
  user@host:~/paired$ find . -name "sample*_1.txt" | sed/awk? | parallel ?
  program ./sampleA-out ./sampleA_1.txt ./sampleA_2.txt
  program ./sampleB-out ./sampleB_1.txt ./sampleB_2.txt
  program ./sampleC-out ./sampleC_1.txt ./sampleC_2.txt
  </code></pre>
  
  <p>Ideally, the command would strip off the _1.txt to create the output directory name (sampleA-out, etc), but I really need to be able to take that argument and change the _1 to a _2 for the second input.</p>
  
  <p>I know this is dead simple with a script - I did this in Perl with a quick regular expression substitution. But I would love to be able to do this with a quick one-liner.</p>
  
  <p>Thanks in advance.</p>