Compare commits
	
		
			22 Commits
		
	
	
		
			1.0
			...
			5d830cbae4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5d830cbae4 | |||
| fb7c410e8a | |||
| e4190bae83 | |||
| 6545189eb0 | |||
| 4e375b5d08 | |||
|   | 2be3db4187 | ||
|   | 9dc5a2550c | ||
|   | 6f82b9eda4 | ||
|   | 28dada6046 | ||
| deeb9080fe | |||
|   | 578119d663 | ||
|   | 23e7a9090a | ||
| 48da83fdd3 | |||
| 82620782b3 | |||
| b1065a657e | |||
| 68a8069739 | |||
|   | 36837548d2 | ||
|   | 407d7ef5c0 | ||
|   | f979f9952d | ||
| 197da26fa9 | |||
| ae9e94b262 | |||
|   | b1871443df | 
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,3 +1,23 @@ | ||||
| # bash-tut | ||||
|  | ||||
| Dateien des bash Tutorioals auf raspithek.de | ||||
|  | ||||
| | Kapitel| Beschreibung           | | ||||
| |--------|------------------------| | ||||
|    1     |Einführung              | | ||||
| |  2     |Prompt                  | | ||||
| |  3     |key bindings            | | ||||
| |  4     |Startvorgang            | | ||||
| |  5     |Environmentvariablen    | | ||||
| |  6     |builtins                | | ||||
| |  7     |Dateien                 | | ||||
| |  8     |nano                    | | ||||
| |  9     |bash Scripting          | | ||||
| | 10     |Variablen               | | ||||
| | 11     |Verzweigungen           | | ||||
| | 12     |Schleifen               | | ||||
| | 13     |Parameter               | | ||||
| | 14     |exit Codes              | | ||||
| | 15     |von der Idee zum Script | | ||||
| | 16     |Funktionen              | | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								alias/noalias.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								alias/noalias.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,2 @@ | ||||
|  | ||||
| ll | ||||
							
								
								
									
										3
									
								
								alias/yesalias.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								alias/yesalias.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| shopt -s expand_aliases  # Aktiviert Aliase | ||||
| alias ll='ls -la' | ||||
| ll | ||||
							
								
								
									
										8
									
								
								piping/debello.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								piping/debello.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. | ||||
|  Hi omnes lingua, institutis, legibus inter se differunt. | ||||
|  Gallos ab Aquitanis Garunna flumen, a Belgis Matrona et Sequana dividit. | ||||
|  Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent, important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. | ||||
|  Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt. | ||||
|  Eorum una pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. | ||||
|  Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. | ||||
|  Aquitania a Garunna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad Hispaniam pertinet; spectat inter occasum solis et septentriones. | ||||
							
								
								
									
										0
									
								
								piping/ls.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								piping/ls.txt
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										23
									
								
								teil02/ansi-consts.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										23
									
								
								teil02/ansi-consts.sh
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										26
									
								
								teil02/ansicolours.sh
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										19
									
								
								teil11/and.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										16
									
								
								teil11/else.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										10
									
								
								teil11/ifeq.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										11
									
								
								teil11/linear.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										19
									
								
								teil11/not.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										19
									
								
								teil11/or.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										14
									
								
								teil11/skip3rd.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										11
									
								
								teil11/strings.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										14
									
								
								teil12/forloop.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										16
									
								
								teil12/noloop.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										12
									
								
								teil12/untilloop.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										12
									
								
								teil12/whileloop.sh
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										5
									
								
								teil13/allparams.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| #! /usr/bin/bash | ||||
| #allparams.sh | ||||
|  | ||||
| echo "${@}" | ||||
|  | ||||
							
								
								
									
										10
									
								
								teil13/paramloop.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								teil13/paramloop.sh
									
									
									
									
									
										Executable 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
									
								
							
							
						
						
									
										14
									
								
								teil13/testparams.sh
									
									
									
									
									
										Executable 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}" | ||||
|  | ||||
							
								
								
									
										10
									
								
								teil14/ifexit.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								teil14/ifexit.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| #! /usr/bin/bash | ||||
|  | ||||
| ./sub.sh ${1} | ||||
|  | ||||
| if [ ${?} -eq 0 ]; then | ||||
|   echo "sub.sh erfolgreich" | ||||
| else | ||||
|   echo "sub.sh fehlgeschlagen" | ||||
| fi | ||||
|  | ||||
							
								
								
									
										4
									
								
								teil14/simpleexit.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								teil14/simpleexit.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| # /usr/bin/bash | ||||
|  | ||||
| echo "Beispiel für exit Code" | ||||
| exit 2 | ||||
							
								
								
									
										10
									
								
								teil14/sub.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								teil14/sub.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # !/usr/bin/bash | ||||
|  | ||||
| if [ "${1}" == "fail" ]; then | ||||
|   echo " ${0}: failing" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
|  | ||||
| exit 0 | ||||
|  | ||||
							
								
								
									
										59
									
								
								teil15/sdcardtester
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										59
									
								
								teil15/sdcardtester
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| #! /usr/bin/bash | ||||
|  | ||||
| MOUNTPOINT='/mnt/speedtest' | ||||
|  | ||||
| # number of threads used during testing | ||||
| nproc=4 | ||||
|  | ||||
| if [ "$EUID" -ne 0 ] | ||||
|   then echo "Please run as root" | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| if [ "${1}" ]; then | ||||
|  DEVICE=${1} | ||||
|  PARTITION=${DEVICE}1 | ||||
|  echo "using device ${DEVICE}" | ||||
| else | ||||
|  echo "using default device ${DEVICE}" | ||||
| fi | ||||
|  | ||||
| # check if sd card is inserted | ||||
| if [ -e ${DEVICE} ]; then | ||||
|   echo "card inserted" | ||||
| else | ||||
|   echo "no sd card found" | ||||
|   exit 2 | ||||
| fi | ||||
|  | ||||
| echo "deleting partion #1" | ||||
| sfdisk --delete -w ${DEVICE} 1 && sync | ||||
|  | ||||
| echo "creating new ext4 partition" | ||||
| echo ",," |sfdisk ${DEVICE} && sync | ||||
|  | ||||
| echo "creating ext4 filesystem on ${PARTITION}" | ||||
| echo "y" |mkfs.ext4 ${PARTITION} | ||||
|  | ||||
| #check if mount point is available, create otherwise | ||||
| if [ ! -d "${MOUNTPOINT}" ]; then mkdir "${MOUNTPOINT}"; fi | ||||
| mount -t ext4 "${PARTITION}" "${MOUNTPOINT}" | ||||
| cd "${MOUNTPOINT}" | ||||
| echo "preparing tests" | ||||
| sysbench fileio --file-total-size=8G prepare > /dev/null | ||||
|  | ||||
| # Test with 16K block size, random read/write | ||||
| echo "run test with 16K block size" | ||||
| sysbench fileio --file-block-size=16K --file-total-size=8G --file-test-mode=rndrw --threads=$(nproc) run | ||||
|  | ||||
| # Test with 1M  block size, random read/write | ||||
| echo "run test with 1M block size" | ||||
| sysbench fileio --file-block-size=1M --file-total-size=8G --file-test-mode=rndrw --threads=$(nproc) run | ||||
|  | ||||
| # cleanup the test files | ||||
| echo "cleaning up test files" | ||||
| sysbench fileio --file-total-size=8G cleanup | ||||
| cd - >/dev/null | ||||
| umount ${PARTITION} | ||||
|  | ||||
|  | ||||
							
								
								
									
										14
									
								
								teil16/loop-func.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								teil16/loop-func.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: loop-func.sh | ||||
|  | ||||
| function hallo() { | ||||
|   echo "Hallo 1" | ||||
|   echo "-------" | ||||
| } | ||||
|  | ||||
| count=1 | ||||
|  | ||||
| while [ ${count} -le 4 ]; do | ||||
|   hallo | ||||
|   count=$((${count} + 1)) | ||||
| done | ||||
							
								
								
									
										14
									
								
								teil16/mult-echo.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								teil16/mult-echo.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: mult-echo.sh | ||||
|  | ||||
| echo "Hallo 1" | ||||
| echo "-------" | ||||
|  | ||||
| echo "Hallo 1" | ||||
| echo "-------" | ||||
|  | ||||
| echo "Hallo 1" | ||||
| echo "-------" | ||||
|  | ||||
| echo "Hallo 1" | ||||
| echo "-------" | ||||
							
								
								
									
										13
									
								
								teil16/param-func.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								teil16/param-func.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: param-func.sh | ||||
|  | ||||
| function hallo() { | ||||
|   echo "Hallo ${1}" | ||||
| } | ||||
|  | ||||
| count=1 | ||||
|  | ||||
| while [ ${count} -le 4 ]; do | ||||
|   hallo "${count}" | ||||
|   count=$((${count} + 1)) | ||||
| done | ||||
							
								
								
									
										14
									
								
								teil16/return-value-echo.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								teil16/return-value-echo.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: return-value-echo.sh | ||||
|  | ||||
|  | ||||
| function square() { | ||||
|  | ||||
|   echo $(( ${1} * ${1} )) | ||||
| } | ||||
|  | ||||
|  | ||||
| square "2" | ||||
| square "4" | ||||
| square "3" | ||||
| square "32" | ||||
							
								
								
									
										20
									
								
								teil16/return-value-echo2.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										20
									
								
								teil16/return-value-echo2.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: return-value-echo2.sh | ||||
|  | ||||
|  | ||||
| function square() { | ||||
|  | ||||
|   echo $(( ${1} * ${1} )) | ||||
| } | ||||
|  | ||||
|  | ||||
| s2=$(square "2") | ||||
| s4=$(square "4") | ||||
| s3=$(square "3") | ||||
| s32=$(square "32") | ||||
|  | ||||
|  | ||||
| echo "Das Quadrat von 2 ist ${s2}" | ||||
| echo "Das Quadrat von 4 ist ${s4}" | ||||
| echo "Das Quadrat von 3 ist ${s3}" | ||||
| echo "Das Quadrat von 32 ist ${s32}" | ||||
							
								
								
									
										18
									
								
								teil16/return-value-return.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								teil16/return-value-return.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: return-value-return.sh | ||||
|  | ||||
|  | ||||
| function square() { | ||||
|  | ||||
|   return $(( ${1} * ${1} )) | ||||
| } | ||||
|  | ||||
|  | ||||
| square "2" | ||||
| echo "Quadrat von 2 ist ${?}" | ||||
| square "4" | ||||
| echo "Quadrat von 4 ist ${?}" | ||||
| square "3" | ||||
| echo "Quadrat von 3 ist ${?}" | ||||
| square "32" | ||||
| echo "Quadrat von 32 ist ${?}" | ||||
							
								
								
									
										33
									
								
								teil16/scope/scope.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								teil16/scope/scope.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| #!/usr/bin/bash | ||||
| # File: scope/scope.sh | ||||
|  | ||||
| # Globale Variable | ||||
| global_var="Ich bin global" | ||||
|  | ||||
| # Funktion mit lokaler Variable | ||||
| funktion_mit_lokaler_var() { | ||||
|     local local_var="Ich bin lokal" | ||||
|     var_ohne_local="Ich bin lokal ohne local" | ||||
|     global_var="Ich wurde in der Funktion verändert" | ||||
|  | ||||
|     echo "Innerhalb der Funktion:" | ||||
|     echo "Globale Variable: ${global_var}" | ||||
|     echo "Lokale Variable: ${local_var}" | ||||
| } | ||||
|  | ||||
| # Hauptskript | ||||
| echo "Vor Funktionsaufruf:" | ||||
| echo "Globale Variable: ${global_var}" | ||||
|  | ||||
| # Funktionsaufruf | ||||
| funktion_mit_lokaler_var | ||||
|  | ||||
| # Nach Funktionsaufruf | ||||
| echo "Nach Funktionsaufruf:" | ||||
| echo "Globale Variable: ${global_var}" | ||||
|  | ||||
| echo "var_ohne_local: ${var_ohne_local}" | ||||
| # Versuch, auf die lokale Variable zuzugreifen (dies wird fehlschlagen) | ||||
| echo "Versuch, auf die lokale Variable außerhalb der Funktion zuzugreifen:" | ||||
| echo "Lokale Variable: ${local_var}" | ||||
|  | ||||
							
								
								
									
										13
									
								
								teil16/simple-func.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								teil16/simple-func.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #! /usr/bin/bash | ||||
| # File: simple-func.sh | ||||
|  | ||||
| function hallo() { | ||||
|   echo "Hallo 1" | ||||
|   echo "-------" | ||||
|  | ||||
| } | ||||
|  | ||||
| hallo | ||||
| hallo | ||||
| hallo | ||||
| hallo | ||||
							
								
								
									
										1
									
								
								teil17/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								teil17/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| backup.txt | ||||
							
								
								
									
										8
									
								
								teil17/familie.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								teil17/familie.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| Simpson, Marge | ||||
| Simpson, Homer | ||||
| simpson, Abe | ||||
| Simpson, Bart | ||||
| Simpson, Lisa | ||||
| Simpson, Maggie | ||||
| Powell, Herb | ||||
|  | ||||
							
								
								
									
										24
									
								
								teil17/schule.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								teil17/schule.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| --- Lehrer ----- | ||||
| Skinner, Seymour | ||||
| Krababel, Edna | ||||
| Hoover, Elisabeth | ||||
| Largo, Dewey | ||||
|  | ||||
| --- Schüler ---- | ||||
| 2: Powell, Janey | ||||
| 2: Wiggum, Ralph | ||||
| 2: Simpson, Lisa | ||||
| 2: Shorter, Becky | ||||
| 2: Taylor, Alison | ||||
| 4: Kyle | ||||
| 4: Clark, Lewis | ||||
| 4: van Houten, Milhouse | ||||
| 4: Simpson, Bart | ||||
| 4: Muntz, Nelson | ||||
| 4: Borton, Wendell | ||||
| 4: Prince, Martin | ||||
| 6: Starbeam, Dolph | ||||
| 6: Jones, Jimbo | ||||
| 6: Zzyswincz, Kearney | ||||
| ?: Zörker, Uter | ||||
|  | ||||
							
								
								
									
										6
									
								
								teil17/snpp.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								teil17/snpp.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| Burns, Monty | ||||
| Smithers, Waylon | ||||
| Carlson, Carl | ||||
| Leonard, Lenny | ||||
| Simpson, Homer | ||||
|  | ||||
							
								
								
									
										7
									
								
								teil20/hello-shebang.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								teil20/hello-shebang.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| #! ./mybang | ||||
| def main(): | ||||
|     print("Hallo aus teil20!") | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
							
								
								
									
										4
									
								
								teil20/hello.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								teil20/hello.js
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| #! /usr/bin/node | ||||
| // Datei: hello.js | ||||
|  | ||||
| console.log('Hallo von JavaScript') | ||||
							
								
								
									
										9
									
								
								teil20/hello.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								teil20/hello.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #! ./mybang | ||||
| # Datei: hello.py | ||||
|  | ||||
| def main(): | ||||
|     print("Hallo von Python") | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
							
								
								
									
										14
									
								
								teil20/mybang
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								teil20/mybang
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #! /usr/bin/bash | ||||
| # Datei: mybang | ||||
|  | ||||
| echo "0:${0}" | ||||
| echo "1:${1}" | ||||
| echo "2:${2}" | ||||
|  | ||||
| if [[ "${USER}" == "pi" ]]; then | ||||
|     echo "User pi darf python ausführen." | ||||
|     python ${1} | ||||
| else | ||||
|     echo "Du darfst kein Python ausführen." | ||||
| fi | ||||
|  | ||||
							
								
								
									
										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 | ||||
							
								
								
									
										59
									
								
								teil23/parseargs.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										59
									
								
								teil23/parseargs.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| #!/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}" | ||||
| } | ||||
		Reference in New Issue
	
	Block a user