Linux Bash If Greater Than Or Less Then Conditions
Page 1 of 1
Linux Bash If Greater Than Or Less Then Conditions
- Code:
#!/bin/bash
# Usage: ./if.sh
#
var=20
if [ "$var" -gt 15 ] # Need spaces between brackets!
then : # do nothing
else
echo "$var" # echo the var if less than true!
fi
Re: Linux Bash If Greater Than Or Less Then Conditions
If = to or not = to that is the question!
- Code:
#!/bin/bash
# Usage: ./if_not.sh 10
#
var=("$@") # User Input
if [ "$var" != 15 ] # Need spaces between brackets!
then : # do something
echo "$var Is NOT Equal To 15"
else
echo "$var Is Equal To 15"
fi
Similar topics
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Linux Bash Who Am I Game Example
» Linux Bash Asci Art
» W3M Linux BASH Commands
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Linux Bash Who Am I Game Example
» Linux Bash Asci Art
» W3M Linux BASH Commands
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|