0

How can I print $$PARAMTER_NM=1234 in a Linux shell? I am getting the PID of my current process with $$, so the output is like:

1943PARAMTER_NM=1234

But I need:

$$PARAMTER_NM=1234
1
2
echo '$$PARAMTER_NM=1234'
$$PARAMTER_NM=1234
1

You can protect the contents of the string from the shell in two possible ways:

  • Escape each $ like \$:

    echo "\$\$PARAMTER_NM=1234"
    
  • Use single quotes:

    echo '$$PARAMTER_NM=1234'
    
0
# echo "\$\$PARAMTER_NM=1234"
$$PARAMETER_NM=1234

If you want to use a special/reserved character with double quotes (such as $) as-is - you need to use an escape character ('\') right before it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.