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

How To Modify a Windows Service

Here's the freebie code: # Version 0.02 $serviceName='Windows_Exporter' $newExePath=$false $newSwitches=" --log.format logger:eventlog?name=$serviceName --collectors.enabled os,cpu,cs,logical_disk,net,tcp,service,textfile" function…

Linux: How to set a static IP address

Set Static IP Address ---- vim /etc/sysconfig/networking/profiles/default/ifcfg-eth0 vim /etc/sysconfig/network-scripts/ifcfg-eth0 ---- DEVICE=eth0 BOOTPROTO=none HWADDR=00:0C:29:d7:5b:d3 ONBOOT=yes TYPE=Ethernet…

PowerShell: Creating Clustered File Shares

# Define Destination Mount Points and UNC Paths $arr=@{} $arr["from"] = @{}; $arr["to"] = @{}…