I was going over some files and found this:
if [[ $# -ge 1 ]]
What does that mean?
The [[ ... ]] part allows to test a condition using operators. Think of it as an if statement.
if is a command in Linux which is used to execute commands based on conditions. The 'if COMMANDS' list is executed. If its status is zero, then the 'then COMMANDS' list is executed.
fi statement is the fundamental control statement that allows Shell to make decisions and execute statements conditionally.
The if statement is composed of the if keyword, the conditional phrase, and the then keyword. The fi keyword is used at the end of the statement. The COMMANDS gets executed if the CONDITION evaluates to True. Nothing happens if CONDITION returns False; the COMMANDS are ignored.
In shell script $# stores the number of arguments passed from the command line, like *argc in c programming.
So, By using the "if" statement we are verify the number of arguments are greater than or equal to one.
if the number of passed parameters is greater than or equal to 1
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