Using variable with cp command in bash shell

Hi,

I am trying to write script to copy some files(/ppscdr/cdrp2p/temp/) from one directory to another directory using shell script. see the script below,

#!/bin/sh -f
dir_name=20061105

        mkdir ${dir_name}
        cd /ppscdr/cdrp2p/temp
        pwd
        cp p2p${dir_name}*.* /ppscdr/cdrp2p/${dir_name}
        pwd

But id dosen't work properly (didn't copy the files).
See the error as below,

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

But there are some files in the /ppscdr/cdrp2p/temp directory starting with p2p20061105.

Can some one help me to find the resolve the error.

p2p${dir_name}*.*

you have a file p2p20061105 file but you are using p2p${dir_name}*.*
why ? i could not understand...

just remove the '*.*" from the script..

I tested with the same it is working..

you will get desired result.

Actually in my cd /ppscdr/cdrp2p/temp contains files as follows,

p2p20061105_1010003_0101.unl
p2p20061105_1010003_0102.unl
..
..
..
p2p20061106_1010003_0101.unl
p2p20061106_1010003_0102.unl
...
...
...
p2p20061130_1010003_0101.unl
so on....

What I want to do is create a new folder called $dir_name and coppy the file
which are starting p2p${dir_name}. Thats why I use the code as above.

dir_name=20061106

    mkdir $\{dir_name\}
    echo $\{dir_name\}
    cd /home/sri/tmp
    pwd
    ls -l p2p$\{dir_name\}\*.* \#check 0/p this command then you come to know what is the problem
    cp p2p$\{dir_name\}\*.* /home/sri/sri1/$\{dir_name\}
    pwd

above this is working perfectly as this is executed from /home/sri/sri1/scrit_name

it is creating a direcoty 20061106 and copy the *.unl file in it

After I remove -f from the first line of the script (
#!/bin/sh -f) script wroked fine. I am confuse what is the problem with -f.

:confused: