From 5a8dbc6347b3541e84fe669b22c17ad3b715e258 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 21 Jan 2026 20:22:09 +0100 Subject: Engage! --- samples/test.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 samples/test.sh (limited to 'samples/test.sh') diff --git a/samples/test.sh b/samples/test.sh new file mode 100644 index 0000000..5696456 --- /dev/null +++ b/samples/test.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# A simple bash script demo + +APP_NAME="MyShellApp" +VERSION="1.0.0" + +echo "Starting $APP_NAME version $VERSION..." + +# Check if a directory exists +if [ -d "/tmp" ]; then + echo "/tmp directory exists." +else + echo "/tmp directory does not exist, creating it..." + mkdir /tmp +fi + +# Loop through arguments +echo "Arguments provided:" +for arg in "$@"; do + echo "- $arg" +done + +# Function definition +greet() { + local name=$1 + echo "Hello, $name!" +} + +# Call function +greet "User" + +# While loop +count=0 +while [ $count -lt 5 ]; do + echo "Count: $count" + ((count++)) +done + +# Case statement +case "$1" in + start) + echo "Starting service..." + ;; + stop) + echo "Stopping service..." + ;; + restart) + echo "Restarting service..." + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +echo "Done." -- cgit v1.2.3