LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cp command problem in script (https://www.linuxquestions.org/questions/linux-newbie-8/cp-command-problem-in-script-506176/)

maheshdf 11-30-2006 05:30 AM

cp command problem in script
 
Hi,

I have som problem in using cp command in shell script. Please see the followoing script,

Code:

#!/bin/sh -f

 dir_temp=20061105
 echo $dir_temp

 mkdir $dir_temp

        cd /ppscdr/cdrp2p/temp
        pwd
        cp /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}

It gives following error,

Code:

[root@cdrwebserver cdrp2p]# ./cp.sh
20061105
/ppscdr/cdrp2p/temp
cp: cannot stat `/ppscdr/cdrp2p/temp/20061105*.unl': No such file or directory

please give me some help to find the error.

pwc101 11-30-2006 05:44 AM

perhaps you need a / between ${dir_temp} and *.unl:
Code:

cp /ppscdr/cdrp2p/temp/${dir_temp}/*.unl /ppscdr/cdrp2p/${dir_temp}

maheshdf 11-30-2006 02:37 PM

no this ${dir_temp}*.unl mean the file need to copy.

benjithegreat98 11-30-2006 04:39 PM

Make
#!/bin/sh -f

to this:
#!/bin/sh

And this:
cp /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}

to this:
cp -r /ppscdr/cdrp2p/temp/${dir_temp}*.unl /ppscdr/cdrp2p/${dir_temp}


All times are GMT -5. The time now is 02:13 AM.