Anders Branderud
Anders Branderud

Reputation: 1918

Bash-script: How to combine a command with a variable name?

I am writing a bash script. I want to be able to change the numbers assigned to -tot_src, etc, in the below line that is included in the bash script. How do I do this?

./eperftool -tot_src=250 -tot_rep=200 -loss=3:200

First step would be to declare e.g. the following:

TOT_SRC = 273

I tried the following, but it is not working:

 ./eperftool -tot_src=$TOT_SRC -tot_rep=200 -loss=3:200

Upvotes: 1

Views: 170

Answers (1)

user unknown
user unknown

Reputation: 36229

In contrast to most programming languages, bash is sensitive to blanks in assignments.

right:

TOT_SRC=273

wrong:

TOT_SRC = 273

Upvotes: 1

Related Questions