Compare commits
34
Commits
1.1
...
815a66d808
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
815a66d808 | ||
|
|
f7336ae3e6 | ||
|
|
e2346fa32f | ||
|
|
ff7035cd22 | ||
|
|
4bd2566b04 | ||
|
|
0d67903acf | ||
|
|
96f5040dfe | ||
|
|
a48e6bc452 | ||
|
|
e64461d64c | ||
|
|
dde357c695 | ||
|
|
c750cb4c69 | ||
|
|
1af089d106 | ||
|
|
dcaafa8604 | ||
|
|
c3f9740332 | ||
|
|
81a7c96f7f | ||
|
|
89557b8e36 | ||
|
|
5d830cbae4 | ||
|
|
fb7c410e8a | ||
|
|
e4190bae83 | ||
|
|
6545189eb0 | ||
|
|
4e375b5d08 | ||
|
|
2be3db4187 | ||
|
|
9dc5a2550c | ||
|
|
6f82b9eda4 | ||
|
|
28dada6046 | ||
|
|
deeb9080fe | ||
|
|
578119d663 | ||
|
|
23e7a9090a | ||
|
|
48da83fdd3 | ||
|
|
82620782b3 | ||
|
|
b1065a657e | ||
|
|
68a8069739 | ||
|
|
36837548d2 | ||
|
|
407d7ef5c0 |
@@ -2,12 +2,22 @@
|
|||||||
|
|
||||||
Dateien des bash Tutorioals auf raspithek.de
|
Dateien des bash Tutorioals auf raspithek.de
|
||||||
|
|
||||||
| Kapitel| Beschreibung|
|
| Kapitel| Beschreibung |
|
||||||
|--------|-------------|
|
|--------|------------------------|
|
||||||
1 |Einführung |
|
1 |Einführung |
|
||||||
| 2 |Hello World |
|
| 2 |Prompt |
|
||||||
| 3 | exit Codes |
|
| 3 |key bindings |
|
||||||
| 4 |Variablen |
|
| 4 |Startvorgang |
|
||||||
| 5 |Verzweigungen|
|
| 5 |Environmentvariablen |
|
||||||
| 6 |Svhleifen |
|
| 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 |
|
||||||
|
|
||||||
|
|||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
ll
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
shopt -s expand_aliases # Aktiviert Aliase
|
||||||
|
alias ll='ls -la'
|
||||||
|
ll
|
||||||
Executable
+66
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# Output colors
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Logging-Funktion
|
||||||
|
log() {
|
||||||
|
echo -e "${GREEN}[INFO]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
warn() {
|
||||||
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo -e "${RED}[ERROR]${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check for root privileges
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "This script must be run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create /boot/firmware dir if it doesn't exist
|
||||||
|
if [ ! -d /boot/firmware ]; then mkdir -p /boot/firmware; fi
|
||||||
|
|
||||||
|
# Enable extended globbing for pattern matching
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
|
# Copy all files from /boot to /boot/firmware and remove the originals
|
||||||
|
log "Moving files to /boot/firmware..."
|
||||||
|
rsync -av --remove-source-files /boot/ /boot/firmware/
|
||||||
|
|
||||||
|
# Update the mount point for /boot in fstab to /boot/firmware
|
||||||
|
log "Updating fstab..."
|
||||||
|
cp -a /etc/fstab /etc/fstab.bak # create backup
|
||||||
|
sed -i 's|^\([^#].*\)[[:space:]]/boot[[:space:]]|\1 /boot/firmware |' /etc/fstab
|
||||||
|
|
||||||
|
# Sync cache and reboot the system to apply changes
|
||||||
|
sync
|
||||||
|
# prompt for reboot
|
||||||
|
echo ""
|
||||||
|
while true; do
|
||||||
|
read -p "Möchtest du das System jetzt neustarten, um die Änderungen zu testen? (J/N): " choice
|
||||||
|
case $choice in
|
||||||
|
[Jj]* )
|
||||||
|
warn "System will be rebooted in 3 seconds"
|
||||||
|
sleep 2
|
||||||
|
reboot
|
||||||
|
;;
|
||||||
|
[Nn]* )
|
||||||
|
log "Neustart übersprungen."
|
||||||
|
log "Bitte starte das System manuell neu, um die Änderungen zu testen."
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
warn "Bitte antworte mit J (Ja) oder N (Nein)."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -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.
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
|
||||||
|
./sub.sh ${1}
|
||||||
|
|
||||||
|
if [ ${?} -eq 0 ]; then
|
||||||
|
echo "sub.sh erfolgreich"
|
||||||
|
else
|
||||||
|
echo "sub.sh fehlgeschlagen"
|
||||||
|
fi
|
||||||
|
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
# /usr/bin/bash
|
||||||
|
|
||||||
|
echo "Beispiel für exit Code"
|
||||||
|
exit 2
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
# !/usr/bin/bash
|
||||||
|
|
||||||
|
if [ "${1}" == "fail" ]; then
|
||||||
|
echo " ${0}: failing"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
Executable
+59
@@ -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}
|
||||||
|
|
||||||
|
|
||||||
Executable
+14
@@ -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
|
||||||
Executable
+14
@@ -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 "-------"
|
||||||
Executable
+13
@@ -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
|
||||||
Executable
+14
@@ -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"
|
||||||
Executable
+20
@@ -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}"
|
||||||
Executable
+18
@@ -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 ${?}"
|
||||||
Executable
+33
@@ -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}"
|
||||||
|
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
# File: simple-func.sh
|
||||||
|
|
||||||
|
function hallo() {
|
||||||
|
echo "Hallo 1"
|
||||||
|
echo "-------"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
hallo
|
||||||
|
hallo
|
||||||
|
hallo
|
||||||
|
hallo
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
backup.txt
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Simpson, Marge
|
||||||
|
Simpson, Homer
|
||||||
|
simpson, Abe
|
||||||
|
Simpson, Bart
|
||||||
|
Simpson, Lisa
|
||||||
|
Simpson, Maggie
|
||||||
|
Powell, Herb
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Burns, Monty
|
||||||
|
Smithers, Waylon
|
||||||
|
Carlson, Carl
|
||||||
|
Leonard, Lenny
|
||||||
|
Simpson, Homer
|
||||||
|
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#! ./mybang
|
||||||
|
def main():
|
||||||
|
print("Hallo aus teil20!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#! /usr/bin/node
|
||||||
|
// Datei: hello.js
|
||||||
|
|
||||||
|
console.log('Hallo von JavaScript')
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#! ./mybang
|
||||||
|
# Datei: hello.py
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hallo von Python")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Executable
+14
@@ -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
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*.bak
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
s/Simpson/Thompson/
|
||||||
|
s/Flanders/Flunders/
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
echo "Hello" | sed 's/Hello/Bye/'
|
||||||
@@ -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,0 +1 @@
|
|||||||
|
*.bak
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
#Datei: teil23/family_case.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
'Homer'|'Marge'|'Bart'|'Lisa') # Familie Simpson
|
||||||
|
echo "Familie Simpson"
|
||||||
|
;;
|
||||||
|
'Ned'|'Maude'|'Todd'|'Rod') # Familie Flanders
|
||||||
|
echo "Familie Flanders"
|
||||||
|
;;
|
||||||
|
'Clancy'|'Sarah'|'Ralph') # Familie Wiggum
|
||||||
|
echo "Familie Wiggum"
|
||||||
|
;;
|
||||||
|
*) # default
|
||||||
|
echo "unbekannte Familie"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Executable
+12
@@ -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 "unbekannte Familie"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*.bak
|
||||||
|
|
||||||
Reference in New Issue
Block a user