Command Dispatcher Pattern Create a script that dispatches commands via switch/case: 1#!/bin/bash 2 3# Command dispatcher script 4command_dispatcher() { 5 local cmd="$1" 6 shift # Remove first argument, rest are parameters 7 8 case "$cmd" in 9 start) 10 echo "Starting service..." 11 # Your start …
Read MoreCommand Dispatcher Pattern 1@echo off 2setlocal 3 4set "command=%~1" 5 6if "%command%"=="start" goto :start 7if "%command%"=="stop" goto :stop 8if "%command%"=="restart" goto :restart 9if "%command%"=="status" goto :status 10goto :usage 11 12:start …
Read MoreCommand Dispatcher Pattern 1# CommandDispatcher.ps1 2param( 3 [Parameter(Mandatory=$true, Position=0)] 4 [string]$Command, 5 6 [Parameter(ValueFromRemainingArguments=$true)] 7 $Arguments 8) 9 10switch ($Command) { 11 "start" { 12 Write-Host "Starting service..." 13 # Your start logic here 14 } 15 …
Read MoreCollection of useful shell commands and scripting techniques across different shells and platforms. Topics Bash Commands & Scripting - Linux/Unix shell scripting and useful commands PowerShell Commands - Windows PowerShell scripting and cmdlets CMD Commands - Windows Command Prompt commands Zsh/Sh Commands - Z …
Read MoreZsh-Specific Features Globbing 1# Recursive globbing 2ls **/.txt 3 4# Exclude pattern 5ls ^.txt 6 7# Numeric ranges 8ls file<1-10>.txt 9 10# Qualifiers 11ls *(.) # Files only 12ls *(/) # Directories only 13ls *(.x) # Executable files 14ls *(m-7) # Modified in last 7 days 15ls *(Lm+100) # Larger than 100MB …
Read More