Skip to content
Advertisement

find and copy command not working in bash

This line works in the terminal, but not in a bash script:

cd /home/me/Downloads/Data/$currentYear/$currentMonth/$currentDay/
find . -name '*.wav' -exec cp {} $tempfolder ;

I’m trying to copy all the WAVE files from all the sub-directories to a temporary folder

Advertisement

Answer

So, I solved it. Turns out, that the cd /home/me/Downloads/Data/$currentYear/$currentMonth/$currentDay/ was not actually changing the directory for the find . to work. The script was trying to find the files in its own directory. Once i wrote find "$absolutePath" -name '*.wav' -exec cp {} "$tempfolder" ; it worked

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement