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 Enable GPUPDATE When Connected via OpenVPN Client

// Explanation: to prevent locking of processes, we set a proxy batch file (on_connect.bat) to…

PowerShell: Disable Virtual Machine Queuing on Hyper-V Hosts

What is VMQ? Virtual Machine Queuing is a shortcut to deliver packet data from the…

PowerShell: How to Send Key Strokes to a Program Graphical User Interface

# WARNING: there's a kill-process command when the target program is already running # so…
Other project: DragonCoin.com