Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash scripts options

#!/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 :: docker compose plugin 
Shell :: npm install less-loader 
Shell :: git merge force 
Shell :: docker update all images 
Shell :: python install z3 
Shell :: powershell check file extension 
Shell :: install openai gym 
Shell :: remove trailing slash 
Shell :: youtube-dl ubuntu 
Shell :: get current branch name git 
Shell :: git change commit id email 
Shell :: nim install 
Shell :: tar.gz files 
Shell :: how to run different python version 
Shell :: grant superuser permission to sudo user ubuntu 
Shell :: select ords version 
Shell :: add user to sudoer 
Shell :: hardhat deploy 
Shell :: sed digits 
Shell :: git sync branch with master 
Shell :: bash float division 
Shell :: public key show 
Shell :: count the numbers of directories in a specific directory 
Shell :: how to see mac address linux 
Shell :: npm add optional dependency 
Shell :: color logging python 
Shell :: conda install numba 
Shell :: file descriptor bash 
Shell :: grep from file 
Shell :: install bootstrap in gatsbyjs 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =