STREBLO STREBLO - 1 year ago 94
Bash Question

Getting command not found bash script

This doesn't make any sense to me, i'm writing a bash script and my script is failing even when all I'm doing is assigning a simple variable.

For example, at the beginning of my script I have:


I've also tried the following:

declare httpd-version="2.4.23"
declare apr-version-var="1.5.2"
declare apr-util-version="1.5.4"
declare pcre-version="8.39"
declare openssl-version="1.0.2h"

I even tried simply writing on the command line:

# pcre-version="8.39"

And I got

-bash: pcre-version=8.39: command not found

I made sure to have the #!/bin/bash at the top. What am I doing wrong?

Answer Source

- is not a valid part of a variable name, try using _ instead

It's being parsed like pcre - version = "8.39"

See this related question on U&L that talks about this

And it's a "Gotcha" here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download