1

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?

5

1 Answer 1

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.