I'm trying to loop through the output of a find command like this -
SRC=`find /path1/ -name file1.jar | head -1`
DST=`find /path2/ -name *metastore.*`
for VAR in $DST
do
cp -v $SRC `dirname $VAR`
done
I get an error in cp
-
Copying /path1/path11/file.jar to /path2/path21/metastore-1.jar
/path2/path22/metastore-2.jar
`/path1/path11/file.jar' -> `/path2/path21/metastore-1.jar\n/path2/path22/metastore-1.jar'
cp: cannot create regular file `/path2/path21/metastore-1.jar\n/path2/path22/metastore-1.jar': No such file or directory
This piece of code executes as part of a build script which fails, but when I try to run the same piece of code independent of the script (on the terminal), it seems to work as expected.
Missing something silly here, will appreciate any help!