-1

I have this line at the end of my bash file:

ab -n 100 -c 10 'https://example.com/?bot_id=$BOT_ID&page_id=$PAGE_ID'

Since I have 2 parameters in my query string, I need to surround the URL with quotes.

The problem is the bash is outputting the variable name ($BOT_ID) instead of the value of it.

How could I output the value inside the quotes?

Asaf Nevo
  • 10,718
  • 22
  • 74
  • 151

2 Answers2

1

Use double quotes so the shell expands the variables; using single quotes keep the value as-is

[root@box ~]# a=5
[root@box ~]# echo '$a'
$a
[root@box ~]# echo "$a"
5

Rule of thumb: always double quote your variables in bash.

from TLDP docs: When referencing a variable, it is generally advisable to enclose its name in double quotes. This prevents reinterpretation of all special characters within the quoted string -- except $, ` (backquote), and \ (escape).

Chen A.
  • 8,778
  • 3
  • 33
  • 51
0

you should use "" :

ab -n 100 -c 10 "https://example.com/?bot_id=$BOT_ID&page_id=$PAGE_ID"
Slim KTARI
  • 254
  • 2
  • 8