Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23d29820b4 | |||
| 01372ed6dd | |||
| ea5900d9ab | |||
| 06f622b37f | |||
| 776ed5ed91 | |||
| 91a330998b | |||
| 7628e01b69 |
19
LICENSE
19
LICENSE
@@ -1,5 +1,18 @@
|
||||
Copyright (C) YEAR by AUTHOR EMAIL
|
||||
MIT License
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
Copyright (c) 2026- raspithek
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
1
teil26/.gitignore
vendored
Normal file
1
teil26/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
test.txt
|
||||
6
teil26/help.txt
Normal file
6
teil26/help.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Dies ist ein Beispiel für
|
||||
einen mehrzeiligen Text,
|
||||
der für einen Hilfetext steht.
|
||||
|
||||
Programm: ${0##*/}"
|
||||
|
||||
13
teil26/version1.sh
Executable file
13
teil26/version1.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
# Version 1: Ausgabe über echo
|
||||
|
||||
usage() {
|
||||
echo "Dies ist ein Beispiel für"
|
||||
echo "einen mehrzeiligen Text,"
|
||||
echo "der für einen Hilfetext steht."
|
||||
echo "Programm: ${0##*/}"
|
||||
}
|
||||
|
||||
usage
|
||||
exit 0
|
||||
10
teil26/version2.sh
Executable file
10
teil26/version2.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
# Version 2: Ausgabe einer externen Datei mit cat
|
||||
|
||||
usage() {
|
||||
cat help.txt
|
||||
}
|
||||
|
||||
usage
|
||||
exit 0
|
||||
17
teil26/version3.sh
Executable file
17
teil26/version3.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
# Version 3: Text als Heredoc innerhalb des Scripts
|
||||
|
||||
usage() {
|
||||
cat <<- EOF
|
||||
Dies ist ein Beispiel für
|
||||
einen mehrzeiligen Text,
|
||||
der für einen Hilfetext steht.
|
||||
|
||||
Programm: ${0##*/}"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
usage
|
||||
exit 0
|
||||
18
teil26/version4.sh
Executable file
18
teil26/version4.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
# Version 3: Text als Heredoc innerhalb des Scripts,
|
||||
# diesmal mit Redirection in eine Datei.
|
||||
|
||||
usage() {
|
||||
cat <<- EOF > test.txt
|
||||
Dies ist ein Beispiel für
|
||||
einen mehrzeiligen Text,
|
||||
der für einen Hilfetext steht.
|
||||
|
||||
Programm: ${0##*/}"
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
usage
|
||||
exit 0
|
||||
71
teil27/family.sh
Executable file
71
teil27/family.sh
Executable file
@@ -0,0 +1,71 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
usage() {
|
||||
local name=${0##*/}
|
||||
|
||||
cat <<-EOF
|
||||
Usage: ${name} [-h || --help] -f || --father <name> -m || --mother <name> -s || --son <name> -d || --daughter <name> -b || --baby <name>
|
||||
|
||||
checks if all members of the Simpsons's family are present: exits 0
|
||||
exists 1 otherwise
|
||||
EOF
|
||||
}
|
||||
FATHER=""
|
||||
MOTHER=""
|
||||
SON=""
|
||||
DAUGHTER=""
|
||||
BABY=""
|
||||
|
||||
VALID_ARGS=$(getopt -o hf:m:s:d:b: --long help,father:,mother:,sun:,daughter:,baby: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "VALID_ARGS=${VALID_ARGS}"
|
||||
eval set -- "$VALID_ARGS"
|
||||
|
||||
while [ : ]; do
|
||||
echo "current parameter: ${1},value=${2}"
|
||||
case "$1" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
shift # simple parameter shift by one
|
||||
;;
|
||||
-f | --father)
|
||||
FATHER=${2}
|
||||
shift 2 # parameter with argument sift two times
|
||||
;;
|
||||
-m | --mother)
|
||||
MOTHER=${2}
|
||||
shift 2
|
||||
;;
|
||||
-s | --son)
|
||||
SON=${2}
|
||||
shift 2
|
||||
;;
|
||||
-d | --daughter)
|
||||
DAUGHTER=${2}
|
||||
shift 2
|
||||
;;
|
||||
-b | --baby)
|
||||
BABY=${2}
|
||||
shift 2
|
||||
;;
|
||||
--) # end of loop
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "unrecognized parameter ${1}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
|
||||
echo "FATHER=${FATHER}"
|
||||
echo "MOTHER=${MOTHER}"
|
||||
echo "SON=${SON}"
|
||||
echo "DAUGHTER=${DAUGHTER}"
|
||||
echo "BABY=${BABY}"
|
||||
55
teil27/getopt_demo.sh
Executable file
55
teil27/getopt_demo.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
help=0
|
||||
verbose=0
|
||||
level=""
|
||||
|
||||
|
||||
# parsing the valid arguments
|
||||
VALID_ARGS=$(getopt -o hvl: --long help,verbose,level: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
eval set -- "$VALID_ARGS"
|
||||
print_params() {
|
||||
count=0
|
||||
for var in "$@"
|
||||
do
|
||||
echo "Param ${count}: ${var}"
|
||||
count=$((${count} + 1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
print_params "$@"
|
||||
echo "VALID_ARGS=${VALID_ARGS}"
|
||||
eval set -- "$VALID_ARGS"
|
||||
print_params "$@"
|
||||
|
||||
while [ : ]; do
|
||||
case "${1}" in
|
||||
-h | --help)
|
||||
help=1
|
||||
shift
|
||||
;;
|
||||
-v | --verbose)
|
||||
verbose=1
|
||||
shift
|
||||
;;
|
||||
-l | --level)
|
||||
level="${2}"
|
||||
shift 2
|
||||
;;
|
||||
--) shift;
|
||||
break
|
||||
;;
|
||||
*) echo "unbekannter Parameter ${1}"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
echo "help=${help}"
|
||||
echo "verbose=${verbose}"
|
||||
echo "level=${level}"
|
||||
|
||||
55
teil27/optional_param.sh
Executable file
55
teil27/optional_param.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
help=0
|
||||
verbose=0
|
||||
level=""
|
||||
|
||||
|
||||
# parsing the valid arguments
|
||||
VALID_ARGS=$(getopt -o hvl:: --long help,verbose,level:: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
eval set -- "$VALID_ARGS"
|
||||
print_params() {
|
||||
count=0
|
||||
for var in "$@"
|
||||
do
|
||||
echo "Param ${count}: ${var}"
|
||||
count=$((${count} + 1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
print_params "$@"
|
||||
echo "VALID_ARGS=${VALID_ARGS}"
|
||||
eval set -- "$VALID_ARGS"
|
||||
print_params "$@"
|
||||
|
||||
while [ : ]; do
|
||||
case "${1}" in
|
||||
-h | --help)
|
||||
help=1
|
||||
shift
|
||||
;;
|
||||
-v | --verbose)
|
||||
verbose=1
|
||||
shift
|
||||
;;
|
||||
-l | --level)
|
||||
level="${2}"
|
||||
shift 2
|
||||
;;
|
||||
--) shift;
|
||||
break
|
||||
;;
|
||||
*) echo "unbekannter Parameter ${1}"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
echo "help=${help}"
|
||||
echo "verbose=${verbose}"
|
||||
echo "level=${level}"
|
||||
|
||||
38
teil27/param_parsing.sh
Executable file
38
teil27/param_parsing.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
help=0
|
||||
verbose=0
|
||||
level=""
|
||||
args=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "${1}" in
|
||||
-h|--help)
|
||||
help=1
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
verbose=1
|
||||
shift
|
||||
;;
|
||||
-l|--level)
|
||||
level="${2}"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
args+=("${1}")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "help=${help}"
|
||||
echo "verbose=${verbose}"
|
||||
echo "level=${level}"
|
||||
|
||||
count=0
|
||||
for var in "${args[@]}"; do
|
||||
echo "Arg ${count}: ${var}"
|
||||
((count++))
|
||||
done
|
||||
|
||||
21
teil27/test_param.sh
Executable file
21
teil27/test_param.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
print_params() {
|
||||
count=0
|
||||
for var in "$@"
|
||||
do
|
||||
echo "Param ${count}: ${var}"
|
||||
count=$((${count} + 1))
|
||||
done
|
||||
}
|
||||
|
||||
VALID_ARGS=$(getopt -o hvl: --long help,verbose,level: -- "$@")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit 1;
|
||||
fi
|
||||
echo "Originalargumente:"
|
||||
print_params "$@"
|
||||
eval set -- "$VALID_ARGS"
|
||||
printf "\nnach eval set:\n"
|
||||
print_params "$@"
|
||||
|
||||
46
teil28/.bash_func
Normal file
46
teil28/.bash_func
Normal file
@@ -0,0 +1,46 @@
|
||||
function extract () {
|
||||
file_type=$(file -b ${1})
|
||||
file_type=${file_type%%,*}
|
||||
|
||||
if [ -f ${1} ] ; then
|
||||
case ${file_type} in
|
||||
"bzip2 compressed data")
|
||||
tar xjvf "${1}"
|
||||
;;
|
||||
"gzip compressed data")
|
||||
gunzip "${1}"
|
||||
;;
|
||||
"XZ compressed data")
|
||||
xz -d "${1}"
|
||||
;;
|
||||
"bzip2 compressed data")
|
||||
bzip2 -d "${1}"
|
||||
;;
|
||||
"RAR archive data")
|
||||
unrar2dir "${1}"
|
||||
;;
|
||||
"POSIX tar archive (GNU)")
|
||||
tar xf "${1}"
|
||||
;;
|
||||
"Zip archive data")
|
||||
unzip "${1}"
|
||||
;;
|
||||
"compress'd data 16 bits")
|
||||
uncompress "${1}"
|
||||
;;
|
||||
"7-zip archive data")
|
||||
7z x "${1}"
|
||||
;;
|
||||
"Zstandard compressed data"*)
|
||||
zstd -d "${1}"
|
||||
;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via extract()"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'${1}' not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
3
teil28/.gitignore
vendored
Normal file
3
teil28/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.tar.gz
|
||||
*.bz2
|
||||
*.zip
|
||||
9
teil28/automkdir.sh
Normal file
9
teil28/automkdir.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
automkdir() {
|
||||
if mkdir "${1}" ; then
|
||||
cd "${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user