Apply command to all files in a directory
6,856
You could use for loop and globbing by filename extension:
for file in *.fna; do
clustalw -align -infile="$file" -outfile="$file.aln"
done
If you want to use a single command, you can use find
:
find . -maxdepth 1 -type f -iname "*.fna" -exec clustalw -infile {} -outfile {}.aln \;
Related videos on Youtube
Author by
Manuel
Updated on September 18, 2022Comments
-
Manuel over 1 year
I want to apply the following command to all the files in the current directory
clustalw -align -infile=*here goes the input filename* -outfile=*here goes the output filename*
I also want the output filename to be the same as the input plus ".aln". For example:
clustalw -align -infile=nexus0000.fna -outfile=nexus000.fna.aln
Thanks for the help!
-
Stéphane Chazelas almost 7 yearsIf you want the equivalent of
-iname "*.fna"
, that would befor file in *.[fF][nN][aA]
or use the extensions that some shells have for case insensitive globs. Note thatfind
will include dotfiles though shell globs won't by default.