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

SQL: Use PowerShell to Generate a Database Object From Another Object

Have you ever wondered about the prospect of automating T-SQL executions on Windows? As your…

Import A WMWare.PowerCLI from Behind the Proxy

VMWare PowerCLI is a must for Administrators. Here's a quick script to install it. If…

PowerShell: Add Network Sites (VLAN) into a Virtual Machine Manager Logical Network

# addVmmNetworkSites.ps1 # version 0.01 # User Defined Variables $networkSites=@( @{ 'newNetworkSitename'="test 1" 'vlanId'=100 'vlanCidr'='192.168.1.0/24'…