I defined the following BASH function to count the number of reads in fastq:
fastq_countGzReads() { zcat "$1" | echo $((`wc -l`/4)) ; }
Now I want to apply this function to a number of gz files found with find.
find . -iname "*gz" -exec sh fastq_countGzReads {} \;
Error:
sh cannot open fastq_countGzReads
How to apply a BASH function on a selection of gz files in a directory ?
A web search on bash find exec function
should bring up several hits that cover various ways to slice-n-dice this.
One idea:
export -f fastq_countGzReads # export the function so it can be
# referenced in a follow-on subshell
### and now a tweak to OP's find/-exec
find . -iname "*gz" -exec bash -c 'fastq_countGzReads {}' \;