Hi, I have a copy statement that needs to execute from a shell script. A sample statement is given below.
cp /data/a/le/lecfil.dbd /bkup2/incr/a/le/lecfil.dbd
The problem is the directory /bkup2/incr/a/le doesn't exist though /bkup2/incr exists. I want my cp command to create the directory if necessary and copy the file to destination.
Can some one help?
Thanks,
Balaji.

Prior to the copy command, you can do a mkdir command to create any missing directories (assuming you have write permissions on the directories): mkdir -p /bkup2/incr/a/le
And if your destination fullpath name is in a variable such as $filename, you could do:
mkdir -p $(dirname $filename)
