Search code examples
unixparameterization

when trying to create file in unix which has $ in that file it is throwing a number?


trying to create a file with following data using shell script.

InsertParam.sh

echo "$$Domain=XYZ" >parameter.prm

when i run InsertParam.sh Am getting out put as

$cat parameter.prm
1979205Domain=XYZ

Please help me how to over come this in my parameter.prm

i need Data as

$$Domain=xyz

Solution

  • In sh/bash/ksh/zsh, $$ is the current PID. see https://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters

    You need to use different quotes to prevent that variable from being expanded:

    echo '$$Domain=XYZ' >parameter.prm
    

    see https://www.gnu.org/software/bash/manual/bashref.html#Quoting


    Quotes can be mixed, as required:

    echo '$$Domain='"$domain" >parameter.prm