1

I have never seen this anywhere in my search I am making a script to see if I can send a string variable to notify-send so far

$MESSAGE='Hello world!'
notify-send "`$MESSAGE`" -t 1

will trow

Hello command not found

and

notify-send $MESSAGE -t 1

sends a too many argument error

so is there a way to do that?

Spark_TheCat
  • 89
  • 1
  • 13

1 Answers1

1

Try this:

MESSAGE='Hello world!'
notify-send "$MESSAGE" -t 1

We declare a variable using NAME=VALUE in bash. There's no $ sign before the variable name. Then you enclose variable value obtained by using $ character using ". The ` character is used as a command substitution, same as $(...).When you write "`$MESSAGE`", you tell you bash to execute command named Hello with argument world!. As such command does not exists, your bash returns Hello command not found.

chepner
  • 497,756
  • 71
  • 530
  • 681
KamilCuk
  • 120,984
  • 8
  • 59
  • 111