Posted On December 18, 2020

Bash Shell Quick If Then and Case Switch Statements

kimconnect 0 comments
blog.KimConnect.com >> Codes , Linux >> Bash Shell Quick If Then and Case Switch Statements
protocol=udp # or tcp

# If-then implementation
if [$protocol == udp]
then
	prefix=@
else
	prefix=@@
fi
  
# Case-switch implementation
case "$protocol" in 
    #case 1
    "udp") prefix=@ ;; 
    #case 2
    "tcp") prefix=@@ ;; 
    #case 3 
    "") prefix=@@ ;; 
esac

echo "$prefix"

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Linux: Performing Speed Test via Command Line Interface (CLI)

Install Speed-Test (if not already installed): kimconnect@linux-client:~$ sudo apt install speedtest-cli Reading package lists... Done…

Function to list Domain Controllers

Wuick Script: # This function runs faster than the "Get-ADDomainController -Filter *" methodfunction listControllers{$domain =…

Ideas for Open Source SAN using local storage

Use a server with local drives Set up Raid 0 Install "SheepDog on Centos/Ubuntu's KVM"…