Reputation: 1
I have a directory with 94 subdirectories, each containing one or two files *.fastq
. I need to apply the same python command to each of these files and produce a new file qc_*.fastq
.
I know how to apply a bash script individually to each file, but I'm wondering if there is a way to write a bash script to apply the command to all the files at once
Upvotes: 0
Views: 149
Reputation: 4928
You can try find . -name "*.fastq" | xargs your_bash_script.sh
, which use find
to get all the files and apply your script to each one of them.
Upvotes: 2
Reputation: 1108
Use find:
find . -type f -iname "*.fastq" -exec python script {} \;
.
: The top-most directory
-type f
: Only files
-iname "*.fastq"
: File name ends in .fastq
(case insensitive)
-exec python script
: The command you want to execute.
Upvotes: 3