Pravin
Pravin

Reputation: 3311

How to print Linux command On terminal

At the time executing following command i get output as i-56816733

str=$" $(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id)"
echo $str

But i want to print the whole command present in 'str' variable with $ sign on terminal as follows :-

$(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id)

I want above output using 'echo' that how can i get ?

Upvotes: 0

Views: 366

Answers (1)

perreal
perreal

Reputation: 97948

Just use single quotes:

str='$(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id)'

if you want interpolation there are two methods, you can append various single quoted strings:

str='$(mkdir'$1')'

or, you can escape the dollar signs you want literal and use double quotes:

str="\$(mkdir $1)"

Upvotes: 2

Related Questions