bash script error to copy files from multiple directories to one directory
1
0
Entering edit mode
23 months ago
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 • 1.0k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode

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

ADD REPLY
2
Entering edit mode
23 months ago
fracarb8 ★ 1.7k

home/ -> /home/

ADD COMMENT
1
Entering edit mode

Thank you so much. Now it is working.

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1988 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6