|
How to Evaluate an Expression in Bash |
|
|
|
|
Friday, 15 October 2010 |
Of course with if statement:
Create a file filename.txt with yes text in it.
echo "ok" > filename.txt
Then use the following Bash code:
example1.sh #!/usr/local/bin/bash var=`cat filename.txt` if [ "$var" = "yes" ]; then echo "yessss!" fi
Line 3 runs command cat filename.txt and then put the output of that command to variable $var.
Line 5 compare content of $var variable with "yes" string and if strings are equal it will display echo on the screen.
|
|
Last Updated ( Friday, 15 October 2010 )
|