My whole Script is currently this:
#!/bin/sh clear; blanko=""; # Dummy-Variablen variable=Testvariable; if [[$variable == $blanko]]; then echo "Nichts da!" else echo $variable fi
and if i enter
TestSelect.sh
i get
/usr/bin/TestSelect.sh: line 6: [[Testvariable: command not found Testvariable
how can i fix this?
When comparing strings in Bash you can use the following operators: string1 = string2 and string1 == string2 - The equality operator returns true if the operands are equal. Use the = operator with the test [ command. Use the == operator with the [[ command for pattern matching.
You can check the equality and inequality of two strings in bash by using if statement. “==” is used to check equality and “!= ” is used to check inequality of the strings. You can partially compare the values of two strings also in bash.
$1 is the first argument (filename1) $2 is the second argument (dir1)
Logical OR Operator ( || ) in Bash It is usually used with boolean values and returns a boolean value. It returns true if at least one of the operands is true. Returns false if all values are false.
This is problem:
if [[$variable == $blanko]];
Spaces are required inside square brackets, use it like this:
[[ "$variable" == "$blanko" ]] && echo "Nichts da!" || echo "$variable"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With