Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash script getopts no argument

#!/bin/bash

while getopts ":a:b:cd" options; do 
# Option -a -b need arguments / -c -d doesn't need argument to work
    case "${options}" in
  		a)
          VARA=${OPTARG}
        ;;
		b)
          VARB=${OPTARG}
        ;;
		c)
          echo "Option -c"
        ;;
		d)
          echo "Option -d"
        ;;
        :)                         # If expected argument omitted:
     	  echo "Error: -${OPTARG} requires an argument."
          exit 1                       
        ;;
        *)                         # If unknown (any other) option:
          echo "Error: unknown option"
          exit 1
        ;;
	esac
done
Comment

PREVIOUS NEXT
Code Example
Shell :: unix check ram 
Shell :: docker console into container 
Shell :: bash loop array 
Shell :: delete folder terminal mac 
Shell :: env npm 
Shell :: bash check for substring in string 
Shell :: shell load file as variable 
Shell :: pip install bootstrap 
Shell :: find out a branch a parent branch git 
Shell :: IlluminateHttpExceptionsPostTooLargeException Ubuntu 
Shell :: install opencv raspberry pi 
Shell :: gnome files command 
Shell :: how to tar 
Shell :: virtualbox guest additions ubuntu 20.04 install 
Shell :: makefile ifeq or 
Shell :: bash copy file and rename 
Shell :: git pull remote changes to local 
Shell :: unzip tar.xz linux 
Shell :: run shell script in dockerfile 
Shell :: get disk partitions linux 
Shell :: calculate float division 
Shell :: linux find string in files in path 
Shell :: lookup function in terraform 
Shell :: change permissions on all sub-directories 
Shell :: ubuntu cmd time 
Shell :: windows scan for corrupt files 
Shell :: run redis in background ubuntu 
Shell :: gitlab reset password 
Shell :: d3 install 
Shell :: gatsby-plugin-react-helmet npm 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =