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
terdon
  • 234,489
  • 66
  • 447
  • 667

3 Answers3

2
echo '$$PARAMTER_NM=1234'
$$PARAMTER_NM=1234
Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
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'
    
Kusalananda
  • 320,670
  • 36
  • 633
  • 936
Enrico
  • 334
  • 3
  • 9
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.

Alex
  • 116
  • 5