Don't use sudo
for normal functions as in sudo cat PA001*.fq > PA001m.fq
. Following may work. Remove --dry-run to execute the command. Make sure that system has enough resources.
$ parallel --dry-run 'cat {=s/_2//=} {=s/_2/_1/=} {} > {=s/_2.fq//=}_m.fq' ::: *_2.fq
bash loop:
$ for i in $(ls *_2.fq); do echo "cat ${i/_2*/.fq} ${i/_2/_1} $i > ${i/_2/_m}";done
Remove echo after checking the dry-run.
without bash loop:
$ find * -type f -name '*.fq' ! -name '*_*.fq' -exec bash -c 'cat {} ${0/./_1.} ${0/./_2.} > ${0/./_m.}' {} ;
Please take a backup of files before you proceed or try with example files in a test directory.