4 Commits
1.0 ... 1.1

Author SHA1 Message Date
Olli Graf
f979f9952d teil11 und teil13 2024-08-18 16:44:07 +02:00
197da26fa9 noloop.sh 2024-07-29 08:02:16 +02:00
ae9e94b262 teil02 teil11 und teil12 2024-07-29 08:01:42 +02:00
Olli Graf
b1871443df erste Scripts für Teil 11 (if) 2024-07-26 12:06:31 +02:00
18 changed files with 262 additions and 1 deletions

View File

@@ -1,3 +1,13 @@
# bash-tut
Dateien des bash Tutorioals auf raspithek.de
Dateien des bash Tutorioals auf raspithek.de
| Kapitel| Beschreibung|
|--------|-------------|
1 |Einführung |
| 2 |Hello World |
| 3 | exit Codes |
| 4 |Variablen |
| 5 |Verzweigungen|
| 6 |Svhleifen |

23
teil02/ansi-consts.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/bash
export ANSI_FG_BLACK="\e[0;30m"
export ANSI_FG_RED="\e[0;31m"
export ANSI_FG_GREEN="\e[0;32m"
export ANSI_FG_YELLOW="\e[0;33m"
export ANSI_FG_BLUE="\e[0;34m"
export ANSI_FG_PURPLE="\e[0;35m"
export ANSI_FG_CYAN="\e[0;36m"
export ANSI_FG_WHITE="\e[0;37m"
export ANSI_NORMAL="\e[0m"
export ANSI_BG_BLACK="\e[40m"
export ANSI_BG_RED="\e[41m"
export ANSI_BG_GREEN="\e[42m"
export ANSI_BG_BROWN="\e[43m"
export ANSI_BG_BLUE="\e[44m"
export ANSI_BG_PURPLE="\e[45m"
export ANSI_BG_TURQUOISE="\e[46m"
export ANSI_BG_GREY="\e[47m"
export ANSI_STYLE_BOLD="\e[1;37m"
export ANSI_STYLE_UNDERLINE="\e[4;37m"

26
teil02/ansicolours.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/bash
. ansi-consts.sh
echo -e "${ANSI_STYLE_UNDERLINE}Liste der ANSI Farbcodes Schriftfarbe${ANSI_NORMAL}"
echo -e "30:${ANSI_FG_BLACK}Schwarz${ANSI_NORMAL}"
echo -e "31:${ANSI_FG_RED}Rot${ANSI_NORMAL}"
echo -e "32:${ANSI_FG_GREEN}Grün${ANSI_NORMAL}"
echo -e "33:${ANSI_FG_YELLOW}Gelb${ANSI_NORMAL}"
echo -e "34:${ANSI_FG_BLUE}Blau${ANSI_NORMAL}"
echo -e "35:${ANSI_FG_PURPLE}Lila${ANSI_NORMAL}"
echo -e "36:${ANSI_FG_CYAN}hell Cyan${ANSI_NoRMAL}"
echo -e "37:${ANSI_FG_WHITE}Weiß${ANSI_NORMAL}"
echo -e "${ANSI_STYLE_UNDERLINE}Liste der ANSI Farbcodes Schriftfarbe${ANSI_NORMAL}"
echo -e "\e[40m schwarz \e[0m"
echo -e "\e[41m rot \e[0m"
echo -e "\e[42m grün\e[0m"
echo -e "\e[43m hellbraun\e[0m"
echo -e "\e[44m blau\e[0m"
echo -e "\e[45m lila\e[0m"
echo -e "\e[46m türkis\e[0m"
echo -e "\e[47m hellgrau\e[0m"
echo -e "${ANSI_STYLE_UNDERLINE}Liste der ANSI Codes Schrifteffekt${ANSI_NORMAL}"
echo -e "\e[1;37mFettdruck${ANSI_NORMAL}"
echo -e "\e[4;37mUnterstrichen${ANSI_NORMAL}"

19
teil11/and.sh Normal file
View File

@@ -0,0 +1,19 @@
#and.sh
counter='1'
test=1
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if [ ${counter} -eq 3 ] && [ ${test} -eq 2 ]; then
echo "0-drei"
fi
if [ ${counter} -eq 3 ] && [ ${test} -eq 1 ]; then
echo "1-drei"
fi
let counter=counter+1
echo "${counter}"

16
teil11/else.sh Normal file
View File

@@ -0,0 +1,16 @@
#else.sh
counter='1'
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if [ ${counter} -ne 3 ]; then
echo "${counter}"
else
echo "drei"
fi
let counter=counter+1
echo "${counter}"

10
teil11/ifeq.sh Normal file
View File

@@ -0,0 +1,10 @@
# ifeq.sh
a=10
if [ ${a} = 10 ]; then
echo "a ist 10"
else
echo "a ist ungleich 10"
fi

11
teil11/linear.sh Normal file
View File

@@ -0,0 +1,11 @@
#linear.sh
counter='1'
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
echo "${counter}"

19
teil11/not.sh Normal file
View File

@@ -0,0 +1,19 @@
#not.sh
counter='1'
test=1
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if ! [ ${counter} -eq 3 ] || [ ${test} -eq 2 ]; then
echo "0-drei"
fi
if [ ${counter} -eq 3 ] || [ ${test} -eq 1 ]; then
echo "1-drei"
fi
let counter=counter+1
echo "${counter}"

19
teil11/or.sh Normal file
View File

@@ -0,0 +1,19 @@
#or.sh
counter='1'
test=1
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if [ ${counter} -eq 3 ] || [ ${test} -eq 2 ]; then
echo "0-drei"
fi
if [ ${counter} -eq 3 ] || [ ${test} -eq 1 ]; then
echo "1-drei"
fi
let counter=counter+1
echo "${counter}"

14
teil11/skip3rd.sh Normal file
View File

@@ -0,0 +1,14 @@
#skip3rd.sh
counter='1'
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if [ ${counter} -ne 3 ]; then
echo "${counter}"
fi
let counter=counter+1
echo "${counter}"

11
teil11/strings.sh Normal file
View File

@@ -0,0 +1,11 @@
#strings.sh
string1='Skinner'
if [[ ${string1} == 'Skinner' ]]; then
echo "Es ist Skinner"
else
echo " Es ist nicht Skinner"
fi

14
teil12/forloop.sh Normal file
View File

@@ -0,0 +1,14 @@
#forloop.sh
#Ausgabe der ungeraden Zahlen bis 10
for i in 1 3 5 7 9; do
echo "i=${i}"
done
#Ausgabe aller Dateien in /etc
for d in /etc/*; do
echo "${d}"
done

16
teil12/noloop.sh Normal file
View File

@@ -0,0 +1,16 @@
# noloop.sh
echo "1"
echo "und"
echo "1"
echo "und"
echo "1"
echo "und"
echo "1"
echo "und"
echo "1"
echo "und"
echo "aus"

12
teil12/untilloop.sh Normal file
View File

@@ -0,0 +1,12 @@
# untilloop.sh
count=1
until [ ${count} -eq 5 ]; do
echo "1"
echo "und"
count=$((${count} + 1))
done
echo "aus"

12
teil12/whileloop.sh Normal file
View File

@@ -0,0 +1,12 @@
# whileloop.sh
count=1
while [ ${count} -le 5 ]; do
echo "1"
echo "und"
count=$((${count} + 1))
done
echo "aus"

5
teil13/allparams.sh Executable file
View File

@@ -0,0 +1,5 @@
#! /usr/bin/bash
#allparams.sh
echo "${@}"

10
teil13/paramloop.sh Executable file
View File

@@ -0,0 +1,10 @@
#! /usr/bin/bash
#paramloop.sh
let count=0
for p in "${@}"; do
echo "Param ${count}: ${p}"
let count=count+1
done

14
teil13/testparams.sh Executable file
View File

@@ -0,0 +1,14 @@
#! /usr/bin/bash
# testparam.sh
echo " Param #0: ${0}"
echo " Param #1: ${1}"
echo " Param #2: ${2}"
echo " Param #3: ${3}"
echo " Param #4: ${4}"
echo " Param #5: ${5}"
echo " Param #6: ${6}"
echo " Param #7: ${7}"
echo " Param #8: ${8}"
echo " Param #9: ${9}"
echo " Param #10: ${10}"