I am currently working in a shell script to automate some things (copying files and preserving their change date). I tested all commands on my shell, but when I run them on a script, they don't behave correctly.If I run this o my shell, I get the appropriate result:$> filename=/home/root/data/ABCD1234/20170123-231000.wav$> echo $filename/home/root/data/ABCD1234/20170123-231000.wav$> cdate=$(date +%Y%m%d%H%M.%S -r $filename)$> echo $cdate201701232310.00$> cp $filename $filename.bck touch -t $cdate $filename.bckBut when I run the following script:#!/bin/bash# list desired filesfiles=$(find /home/root/data/ABCD1234/*)# iterate over every file foundfor filename in $filesdo    echo $filename    cdate=$(date +%Y%m%d%H%M.%S -r $filename)    echo $cdate    cp $filename $filename.bck     touch -t $cdate $filename.bckdoneexit 0I get the following output (assuming there are 2 files in this folder)/home/root/data/ABCD1234/20170123-231000.wav': No such file or directory/data/ABCD1234/20170123-231000.wav/home/root/data/ABCD1234/20170123-231500.wav': No such file or directory/data/ABCD1234/20170123-231500.wavPS: I am using an ARAGO distro and most shell commands are a redirect to BusyBox.PS: In my original script I am not actually copying files, so keeping timestamp on the cp command won't solve my problem.
File not found while running a sh script
linux;bash;shell script