Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash scripts options without arg

#!/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 :: install docker compose in linux 
Shell :: add gif to readme.so 
Shell :: ubuntu spotify 
Shell :: merge remote commits to local then push 
Shell :: wireshark para ubuntu 
Shell :: copy one branch to another git 
Shell :: bash store file in array 
Shell :: composer xampp windows 
Shell :: how to check the parent branch in git 
Shell :: install wireshark ubuntu 
Shell :: install opencv 
Shell :: how to update an existing repository in github 
Shell :: files tar.gz 
Shell :: how to create a host driver in docker 
Shell :: rsync with ssh key 
Shell :: how to kill a process in powershell 
Shell :: remove users from linux 
Shell :: linux ssh with password in one line 
Shell :: erlang clear shell 
Shell :: flutter create command 
Shell :: bash calculate division 
Shell :: docker-compose change working dir 
Shell :: linux scroll in flutter 
Shell :: remove app with snap 
Shell :: change file name in terminal 
Shell :: colorlog python 
Shell :: ubuntu power settings high performance 
Shell :: shell script get branch name 
Shell :: git set head to commit 
Shell :: google translate for linux 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =