I am trying to run this command
for c in ax
do
mkdir $TgtDir$c/$Date
cd $TgtDir$c/$DirNew
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $DIR
echo find . -iname $tgt -exec cp --parents {} ../$Date \;
find . -iname $tgt -exec cp --parents {} ../$Date \;
done
it prints
/home/ax/new
find . -iname '*20170829*' -exec cp --parents {} ../20170829 ;
but doesnt copy anything. If I run the command that is echoed here (after adding the \ at the end, seems like echo is swallowing that as an escape) from the new directory, it works fine - and the files get copied into /home/ax/20170829/....
Any ideas what I am missing here?