BASH-Tippen Kurs zum Erlernen und Üben typischer Bash-Befehle, Dateipfade, Optionen, Umleitungen, Pipes und Shell-Skripte. Ausgelegt für eine deutsche QWERTZ-Tastatur. Grundzeile und einfache Wörter asdf jklö asdf jklö asdf jklö fall lass das alles date fasse lade ls ls ls pwd pwd pwd Erste Bash-Befehle g h r u i e n t ls pwd cd clear date whoami hostname echo Dateien und Verzeichnisse m b c v x z ls -l ls -a pwd cd .. cd / cd ~ mkdir test touch datei rm datei rmdir test Pfade und Verzeichnisnavigation / . - _ cd /tmp cd /var/log cd ~/Dokumente ls ./datei ls ../ pwd mkdir -p projekt/src cd projekt cd src cd .. Dateien kopieren und verschieben p ö ä ü cp datei kopie mv kopie archiv mkdir archiv cp datei archiv/ mv archiv/kopie archiv/alt rm archiv/alt Optionen und lange Befehle q w y ö ä ü ls -lah ls --all ls --human-readable mkdir --parents projekt/src cp --interactive datei ziel rm --interactive datei Ausgabe und Umleitungen > < | & echo hallo echo hallo > datei cat datei echo welt >> datei cat < datei cat datei | sort cat datei | less sleep 10 & Pipes und Textverarbeitung s o k f ls -l | less ps aux | less cat /etc/passwd | sort grep root /etc/passwd ls -l | grep txt cat datei | wc -l history | tail Suchen mit find und grep n d v find . -name "*.txt" find /tmp -type f grep hallo datei grep -r hallo . grep -i fehler log.txt find . -type f | sort Variablen und Umgebungsvariablen $ = " ' { } name="Bash" echo "$name" echo "${name}" home="$HOME" echo "$home" export EDITOR=vim echo "$PATH" Bedingungen und Rückgabewerte [ ] ! - test -f datei [ -f datei ] [ -d projekt ] [ ! -e alt ] echo $? command -v bash which bash Schleifen und kleine Skripte for do done in if then fi for file in *.txt; do echo "$file" done if [ -f datei ]; then echo "Datei vorhanden" fi Bash-Kommandos im Fließtext mkdir -p ~/projekt/{src,bin,doc} cd ~/projekt touch src/main.sh chmod +x src/main.sh echo '#!/usr/bin/env bash' > src/main.sh echo 'echo hallo' >> src/main.sh ./src/main.sh Abschlussübung #!/usr/bin/env bash projekt="$HOME/bash-training" mkdir -p "$projekt" cd "$projekt" || exit 1 for name in eins zwei drei; do echo "$name" > "$name.txt" done find . -type f -name "*.txt" | sort | while read -r file; do echo "Datei: $file" wc -l "$file" done