Find command in Shell Script

Hi

In the follwoing script

--------

#!/bin/sh
var1=`date +"%Y%m%d"`
echo $var1
find . -name "*${var1}*" | xargs -I{} cp {} ./Delete/

--------
The command find . -name "*${var1}" | xargs -I{} cp {} ./Delete/ is not ececuting
But when I run it on shell $ find . -name "*${var1}
" | xargs -I{} cp {} ./Delete/ it executes.

The same command fails to execute when it is inside the script but executes when used in command prompt.

I am using ksh shell

1) Did you chmod +x <yourscript> ?
2) Which way do you launch it ?

yourscript
./yourscript
ksh yourscript
ksh ./yourscript

or another way ?

Hi

I did'nt chmod my script

I am launching it by following command

$ /bin/sh new.sh

I am concerned that the directory "Delete" appears to be directly under the directory where the "find" starts.
The first time we run the files matching the criteria are copied to the sundirectory. The second time we run we try to copy the files in "Delete" to themselves.
There should be error messages like "are identical" from this script.

????
Just for fun...

an12:/home/vbe $ touch 20101125
an12:/home/vbe $ test0003         
20101125
 found:  ./20101125
an12:/home/vbe $ ll test0003
-rwxr-xr-x    1 vbe      sdso          156 Nov 25 18:01 test0003
an12:/home/vbe $ cat test0003
#!/bin/sh
var1=`date +"%Y%m%d"`
echo $var1
find . -name "*${var1}*" | xargs -I{} echo " found: " {} 
#find . -name "*${var1}*" | xargs -I{} cp {} ./Delete/
an12:/home/vbe $  oslevel
6.1.0.0