Site icon EdwardsLab

BASH commands: number of arguments supplied

bash

GNU Bourne Again Shell

This code checks for the number of arguments supplied to a bash script

if [[ $# -eq 0 ]]; then echo "No arguments supplied"; exit; fi 

If there are no arguments you probably don’t need to do anything.

Remember the arguments are:

$0 - the name of the script
$1 - the first argument
$2 - the second argument
Exit mobile version