#!/bin/bash # Check spell http://www.shellcheck.net/# online, or download, to test!# Bash have variable when call an executable, $0 = CommandName, $1..$N = ArgumentsargumentsLimit=1commandName=$(basename "$0")commandPath=${0%/*}argumentsRequired="first second"###### Function declaration# My first function, display usage infof_display_usage(){echo"This script require arguments!"echo -e "\nUsage:\n$0 [${argumentsRequired}] \n"}# My second function, check iff_check_correct_parameters(){# if less than ${argumentsLimit} arguments supplied, display usage if[$# -le ${argumentsLimit}]then display_usage
exit1fi}f_main(){echo"------- My second script begins execution..."echo"--------------------------------------------"echo" Executing command: ${commandName}"echo" At path: ${commandPath}"echo" You want to have ${argumentsLimit} and provide ${#}"f_check_correct_parameters
# check whether user had supplied -h or --help . If yes display usage if[[($#=="--help")||$#=="-h"]]then display_usage
exit0fiecho"------- My second script end now!"echo"---------------------------------"}###### End Function declaration# Call mainf_main
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.