#!/bin/bash # Bash have variable when call an executable, $0 = CommandName, $1..$N = ArgumentsargumentsLimit=1commandName=$(basename "$0")argumentsRequired="first second"display_usage(){echo"This script require arguments!"echo -e "\nUsage:\n$0 [${argumentsRequired}] \n"}# echo" Executing command: ${commandName}"echo" You want to have ${argumentsLimit} and provide ${#}"# if less than two arguments supplied, display usage if[$# -le ${ArgumentsLimit}]then display_usage
exit1fi# check whether user had supplied -h or --help . If yes display usage if[[($#=="--help")||$#=="-h"]]then display_usage
exit0fi# display usage if the script is not run as root user if[[$USER !="root"]];thenecho"This script must be run as root!"exit1fiecho"All good !!!"
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.