Browse Source

teil02 teil11 und teil12

master
Olli Graf 3 months ago
parent
commit
ae9e94b262
  1. 10
      README.md
  2. 23
      teil02/ansi-consts.sh
  3. 26
      teil02/ansicolours.sh
  4. 9
      teil11/and.sh
  5. 19
      teil11/not.sh
  6. 19
      teil11/or.sh
  7. 14
      teil12/forloop.sh
  8. 12
      teil12/untilloop.sh
  9. 12
      teil12/whileloop.sh

10
README.md

@ -1,3 +1,13 @@
# bash-tut
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

@ -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

@ -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}"

9
teil11/and.sh

@ -1,14 +1,19 @@
#and.sh
counter='1'
test=1
echo "${counter}"
let counter=counter+1
echo "${counter}"
let counter=counter+1
if [ ${counter} -eq 3 ] && [ ${counter} -gt 2 ]; then
echo "drei"
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/not.sh

@ -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

@ -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
teil12/forloop.sh

@ -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

12
teil12/untilloop.sh

@ -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

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