Matt Thornton
Matt Thornton

Reputation: 157

Bash For Loop with multiple input files of the same name

I am trying to combine a matched set of files with a For loop through a directory of files.

The files look like samename.csfasta and samename.qual, only the extensions are different.

The command to execute the program is:

solid2fastq samename.csfasta samename.qual -o samename

I have been looking for an example online but haven't found one.

if there were only one input:

for f in $FILES
do
     echo "Processing $f file....."
     solid2fastq $f -o $f

done

TIA

Upvotes: 0

Views: 817

Answers (1)

gipi
gipi

Reputation: 2515

If the files (.cfasta and .qual) are coupled then a code like the following

FILES=( *.csfasta )
for f in "${FILES[@]}"
do
  base=$(basename "$f" .csfasta)
  echo "Processing $f file....."
  solid2fastq "$f" "${base}.qual" -o "$base"
done

should be useful.

Upvotes: 2

Related Questions