1#!/bin/bash
 2
 3# A simple bash script demo
 4
 5APP_NAME="MyShellApp"
 6VERSION="1.0.0"
 7
 8echo "Starting $APP_NAME version $VERSION..."
 9
10# Check if a directory exists
11if [ -d "/tmp" ]; then
12    echo "/tmp directory exists."
13else
14    echo "/tmp directory does not exist, creating it..."
15    mkdir /tmp
16fi
17
18# Loop through arguments
19echo "Arguments provided:"
20for arg in "$@"; do
21    echo "- $arg"
22done
23
24# Function definition
25greet() {
26    local name=$1
27    echo "Hello, $name!"
28}
29
30# Call function
31greet "User"
32
33# While loop
34count=0
35while [ $count -lt 5 ]; do
36    echo "Count: $count"
37    ((count++))
38done
39
40# Case statement
41case "$1" in
42    start)
43        echo "Starting service..."
44        ;;
45    stop)
46        echo "Stopping service..."
47        ;;
48    restart)
49        echo "Restarting service..."
50        ;;
51    *)
52        echo "Usage: $0 {start|stop|restart}"
53        exit 1
54        ;;
55esac
56
57echo "Done."