Unix copy command

Hi,

I have the below command running in unix

find /dev/data/ -name "*.*" -exec cp -R {} "/isdev/data//history" \;

This command will copy the files from /dev/data/ to /isdev/data//history and will not throw even if there is no files in source.

But if i modify the path from /isdev/data//history to /isdev/data/history1
the command is not failing( history1 folder doesn't appear in unix server) instead the command is creating a file called history1 in /isdev/data/ folder.

This there anyway to alter the command to fail if the path is invalid.

Use

[ -z "$dest_dir" ]

which would check the existence of the directory.

w020637

[leiyang@localhost drivers]$ find . -name "*.ko" -exec cp -R {} "/home/leilyang/12"
find: missing argument to `-exec'

why?

find . -name "*.ko" -exec cp -R '{}' "/home/leilyang/12" \;

the {} means what, where can I get its usage?

Check the man page of find.

Regards

Unix is not a MSDOS. Filename *.* does not have the same meaning in unix as MSDOS and can cause you to miss files. In your case it will miss directories unless the directory name contains a full stop character.
The command sequence posted may be nearly giving the right results by accident. it is however not correct.

After re-reading your post several times I am not 100% clear what you are trying to do.

Are there any subdirectories under /dev/data ?
Are there any files directly under /dev/data ?
If there are subdirectories, do you you want to replicate that tree under /isdev/data/history ?
If so you should really be looking at unix "cpio -p" not "cp -R". This will also address your problem of "cp -R" creating the directory tree one level down.

For example (but do check your local "man cpio").

cd /dev/data
TARGET="/isdev/data/history"
if [ -d "${TARGET}" ]
then
         find . -print|cpio -pdum "${TARGET}"
else
         echo "Directory missing: ${TARGET}"
fi