Compare commits
10 Commits
1.3
...
c750cb4c69
Author | SHA1 | Date | |
---|---|---|---|
c750cb4c69 | |||
1af089d106 | |||
dcaafa8604 | |||
c3f9740332 | |||
81a7c96f7f | |||
89557b8e36 | |||
5d830cbae4 | |||
fb7c410e8a | |||
e4190bae83 | |||
6545189eb0 |
1
teil21/.gitignore
vendored
Normal file
1
teil21/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.bak
|
2
teil21/commandlist.txt
Normal file
2
teil21/commandlist.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
s/Simpson/Thompson/
|
||||||
|
s/Flanders/Flunders/
|
1
teil21/commands.txt
Normal file
1
teil21/commands.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
echo "Hello" | sed 's/Hello/Bye/'
|
16
teil21/families.txt
Normal file
16
teil21/families.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Simpson, Marge
|
||||||
|
Simpson, Homer
|
||||||
|
Simpson, Maggie
|
||||||
|
Simpson, Lisa
|
||||||
|
Simpson, Bart
|
||||||
|
|
||||||
|
#FLANDERS-START
|
||||||
|
Flanders, Maude
|
||||||
|
Flanders, Ned
|
||||||
|
Flanders, Rod
|
||||||
|
Flanders, Todd
|
||||||
|
#FLANDERS-END
|
||||||
|
|
||||||
|
Wiggum, Sarah
|
||||||
|
Wiggum, Clancy
|
||||||
|
Wiggum, Ralph
|
0
teil22/ebene0/0.txt
Normal file
0
teil22/ebene0/0.txt
Normal file
1
teil23/.gitignore
vendored
Normal file
1
teil23/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.bak
|
19
teil23/family_case.sh
Executable file
19
teil23/family_case.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
#Datei: family_case.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
'Homer'|'Marge'|'Bart'|'Lisa')
|
||||||
|
echo "Familie Simpson"
|
||||||
|
;;
|
||||||
|
'Ned'|'Maude'|'Todd'|'Rod')
|
||||||
|
echo "Familie Flanders"
|
||||||
|
;;
|
||||||
|
'Clancy'|'Sarah'|'Ralph')
|
||||||
|
echo "Familie Wiggum"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unbekannte Familie"
|
||||||
|
;;
|
||||||
|
esac
|
12
teil23/family_if.sh
Executable file
12
teil23/family_if.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# Datei teil23/family_if.sh
|
||||||
|
|
||||||
|
if [[ "${1}" == "Homer" || "${1}" == "Marge" || "${1}" == "Bart" || "${1}" == "Lisa" ]]; then
|
||||||
|
echo "Familie Simpson"
|
||||||
|
elif [[ "${1}" == "Ned" || "${1}" == "Maude" || "${1}" == "Todd" || "${1}" == "Rod" ]]; then
|
||||||
|
echo "Familie Flanders"
|
||||||
|
elif [[ "${1}" == "Clancy" || "${1}" == "Sarah" || "${1}" == "Ralph" ]]; then
|
||||||
|
echo "Familie Wiggum"
|
||||||
|
else
|
||||||
|
echo "unbekante Familie"
|
||||||
|
fi
|
1
teil24/.gitignore
vendored
Normal file
1
teil24/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.bak
|
70
teil24/parseargs.sh
Executable file
70
teil24/parseargs.sh
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
display_help() {
|
||||||
|
echo "Usage: ${0} [options]"
|
||||||
|
echo "Options:"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
echo " -v, --verbose Enable verbose mode"
|
||||||
|
echo " -f, --file <file> Specify a file"
|
||||||
|
echo " -n, --number <num> Specify a number (default: 42)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Universelle Parameterparser-Funktion
|
||||||
|
parse_args() {
|
||||||
|
POSITIONAL=()
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
display_help "$@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-v|--verbose)
|
||||||
|
VERBOSE=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-f|--file)
|
||||||
|
if [[ -z "$2" || "$2" == -* ]]; then
|
||||||
|
echo "Error: --file requires a non-empty argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
FILE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-n|--number)
|
||||||
|
if [[ -z "$2" || "$2" == -* ]]; then
|
||||||
|
echo "Error: --number requires a non-empty argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
NUMBER="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--) # Explicit end of options
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-*) # Unknown option
|
||||||
|
echo "Error: Unknown option $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*) # Positional argument
|
||||||
|
POSITIONAL+=("$1")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
set -- "${POSITIONAL[@]}" # Restore positional parameters
|
||||||
|
|
||||||
|
# Defaults
|
||||||
|
VERBOSE="${VERBOSE:-false}"
|
||||||
|
NUMBER="${NUMBER:-42}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Aufruf der Funktion mit allen Skriptargumenten
|
||||||
|
parse_args "$@"
|
||||||
|
|
||||||
|
# Beispielnutzung
|
||||||
|
echo "Verbose mode: $VERBOSE"
|
||||||
|
echo "File: ${FILE:-<not set>}"
|
||||||
|
echo "Number: $NUMBER"
|
||||||
|
echo "Positional arguments: $@"
|
||||||
|
|
Reference in New Issue
Block a user