• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

bash: compare a variable to a text string

Hello!

I'd like to know how, in my bash script, I can compare a variable to a text string.. just like in php:

if ($blabla == "ohohoh") { ... }

The variable needs to be compared to a text string, no numbers 🙂


Thanks all! Frank
 
Thanks for searching but I've been working on this problem for more than two hours and, according to this how-to:

if [ "$bla" = "blabla" ]; then

should work as asked, but in fact, all it says is an error such as:

./blabla: line 16: [blabla: command not found

This error is all I could get in the hours I worked on this problem 🙁


Frank
 
[" is not at all the same as [ ". That's like trying to do ls*.jpg instead of ls *.jpg

Look at the output of: ls -l `which [` edit: nm on that

well, [ is the same command as "test". It's a command, not a shell syntax construct.
 
Ahhh, needed a blank space between the " and the [ ]'s... Can't beleive I lost all this time on a dumb problem like this one :S

Thanks again folks!
 
Back
Top