Bash script display usage and check user - Linux Tutorials - Learn Linux Configuration

Sometimes it is needed to check what user is executing the bash script and whether the user supplied all required arguments:


This is a companion discussion topic for the original entry at https://linuxconfig.org/bash-script-display-usage-and-check-user/

echo -e "\nUsage: \$0 [arguments] \n" echo -e "\nUsage: $0 [arguments] \n"
$ should not be escaped.

This will be fixed shortly. Thank you for bringing this to my attention and for your support…

1 Like
if [[ ( $# == "--help") ||  $# == "-h" ]] 

must be

if [[ ( $* == "--help") ||  $* == "-h" ]]