0

I have multiple filenames in files.txt. I want to run three scripts on each file. I my suggestion correct?

files.txt:

SRR13143.sra
SRR44234.sra
SRR23424.sra

my try:

for FILE in "file.txt";
do
prefetch --max-size 300G $FILE
fastq-dump --gzip --split-3 $FILE
rm $FILE;
done
2
  • You're not reading filenames from file.txt, you're just looping over the name file.txt literally. Commented Jan 30, 2019 at 18:17
  • BTW, you should always quote variables unless you have a good reason not to. Commented Jan 30, 2019 at 18:17

1 Answer 1

2

You want a while loop instead.

while IFS= read -r FILE; do
  prefetch --max-size 300G "$FILE"
  fastq-dump --gzip --split-3 "$FILE"
  rm "$FILE"
done < file.txt
Sign up to request clarification or add additional context in comments.

3 Comments

Maybe as a finishing touch, prefer lower case for your private variable.
Might want to redirect the commands in the loop </dev/null if we don't know them not to consume stdin, just out of caution. Or put file.txt on an alternate fd.
If one of the script adds a extenstion to the output, for instance SRR13143.sra.gz, could I write: "$FILE".gz ??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.