Files
work/ktouch/custom_courses/bash.xml
T
2026-09-08 08:43:48 +02:00

221 lines
4.4 KiB
XML

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