ディレクトリ内のすべてのファイルにコマンドを適用する

ディレクトリ内のすべてのファイルにコマンドを適用する

現在のディレクトリのすべてのファイルに次のコマンドを適用したい

clustalw -align -infile=*here goes the input filename* -outfile=*here goes the output filename*

また、出力ファイル名が入力ファイル名に「.aln」を加えたものと同じになりたい。たとえば、

clustalw -align -infile=nexus0000.fna -outfile=nexus000.fna.aln

助けてくれてありがとう!

ベストアンサー1

forループを使用し、ファイル拡張子としてglobbingを使用できます。

for file in *.fna; do
    clustalw -align -infile="$file" -outfile="$file.aln"
done

単一のコマンドを使用するには、次のものを使用できますfind

find . -maxdepth 1 -type f -iname "*.fna" -exec clustalw -infile {} -outfile {}.aln  \;

おすすめ記事