This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bash script error to copy files from multiple directories to one directory
for FILE in home/tinas/MAGs_12_example_data/12_MAGs_seq.fna/dir_extension_checkm/tina/prokka_annotation/**/*.gff
do
        cp $FILE /home/tinas/MAGs_12_example_data/12_MAGs_seq.fna/dir_extension_checkm/tina/prokka_annotation/all_gff_file/
done

This command is working fine in terminal but in bash script this shows No such file or directory. Can anybody help me out with this command?

bash

Hi, not sure why this loop is necessary. cp can copy multiple files at once. cp /home/.../*.gff /home/.../destination works, note you are lacking a single "/" in your source dir.

After you have run this for the first time, if you run it again, you will get an error that you are trying to copy a file onto itself.

I tried cp **/*.gff /home/tinas/MAGs_12_example_data/12_MAGs_seq.fna/dir_extension_checkm/tina/prokka_annotation/all_gff_file/ in bash script but it was not working.

cp */*.gff otherwise you will copy the hidden file .gff

1 answer

home/ -> /home/

I moved the comment to answer, please accept it (the checkmark symbol) if it solved the issue.

Log in to answer this question.