0

input, which contains data inside

WT_rep1_noFilter.Cov4.common.WT_rep1_vs_mutant1.txt mutant1_noFilter.Cov4.common.WT_rep1_vs_mutant1.txt

WT_rep1_noFilter.Cov4.common.WT_rep1_vs_mutant2.txt mutant2_noFilter.Cov4.common.WT_rep1_vs_mutant2.txt

WT_rep1_noFilter.Cov4.common.WT_rep1_vs_mutant3.txt mutant3_noFilter.Cov4.common.WT_rep1_vs_mutant3.txt

...

I can do some processing as following one by one:

Rscript (my script) WT_rep1_noFilter.Cov4.common.WT_rep1_vs_mutant1.txt mutant1_noFilter.Cov4.common.WT_rep1_vs_mutant1.txt > output_mutant1.txt

However, I have bench of mutants (> 30 mutants).

Does someone knows is it possible to make a bash loop (for f in ...) to do this job at the same time?

Thanks

Ming
  • 1
  • 1
  • The key difference from the ["Find matching pairs of files" duplicate](https://stackoverflow.com/questions/42596768/bash-find-matching-pairs-of-files) is that you'll want to trim and replace prefixes, not suffixes. Thus, `for i in WT_rep*mutant*; do j=mutant${i##*mutant}${i#WT_rep}; ...`, as described in the ["Strip prefix from variable" duplicate](https://stackoverflow.com/questions/33547904/strip-prefix-from-variable-bash). – Charles Duffy Oct 18 '17 at 21:00
  • To spell it out: `for i in WT_rep*mutant*; do j=mutant${i##*mutant}${i#WT_rep}; Rscript "$i" "$j" >"output_mutant${i##*mutant}.txt"; done`. Precede with `set -x` if you want to see the details of what it does. – Charles Duffy Oct 18 '17 at 21:11

0 Answers0