0

I have the following bash script:

#!/bin/bash

for r in $(find . -name "*.fastq");
do

  cat <<EOF
  #qsub <<EOF
#!/bin/bash -l

#PBS -N $r

EOF

done

Unfortunately, all filename get split:

> sh  cFiltering_pbs.sh 
  #qsub <<EOF
#!/bin/bash -l

#PBS -N ./76A

  #qsub <<EOF
#!/bin/bash -l

#PBS -N Paired.fastq

  #qsub <<EOF
#!/bin/bash -l

#PBS -N ./104A

  #qsub <<EOF
#!/bin/bash -l

#PBS -N Paired.fastq

Here is the find output:

find . -name "*.fastq"
./76A Paired.fastq
./104A Paired.fastq

What did I miss?

2

Instead of using find you can simply loop through the files themselves. Notice that I have double-quoted "$r"; you need to do that to keep the space in the filenames intact and unparsed by the shell.

for r in *.fastq
do
    # Stuff using "$r"...
    :
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.