Back openDesk Edu for a sovereign, open-source education — every vote counts.
Vote nowSave products you love by clicking the heart icon.
Complete Docker Compose command reference covering project setup, service management, networking, volumes, and troubleshooting.
Ein praktischer Quick-Reference-Guide für die wichtigsten Unix/Linux-Kommandozeilen-Tools. Die Befehle sind nach Kategorien organisiert, ergänzt durch gängige Flags und realistische Beispiele.
Suche nach Dateien und Verzeichnissen mit leistungsstarken Filteroptionen.
# Find by name (case-sensitive)
find /path -name "*.txt"
# Find by name (case-insensitive)
find /path -iname "*.TXT"
# Find files only
find /path -type f
# Find directories only
find /path -type d
# Find with max depth
find /path -maxdepth 3 -name "*.js"
# Find files larger than 100MB
find /path -size +100M
# Find files smaller than 1KB
find /path -size -1k
# Find files between 1MB and 10MB
find /path -size +1M -size -10M
# Modified in last 7 days
find /path -mtime -7
# Modified more than 30 days ago
find /path -mtime +30
# Accessed in last hour
find /path -amin -1
# Delete found files
find /path -name "*.tmp" -delete
# Execute command on each file
find /path -name "*.log" -exec rm {} \;
# Execute with confirmation
find /path -name "*.bak" -ok -exec rm {} \;
# Find JS files modified in last week,find /path -name "*.js" -mtime -7
# Find large log files
find /path -name "*.log" -size +10M
# Find empty directories
find /path -type d -empty
# Find files by permission
find /path -perm 755
Suche nach Textmustern in Dateien.
# Search in file
grep "pattern" file.txt
# Search in multiple files
grep "pattern" *.txt
# Case-insensitive search
grep -i "pattern" file.txt
# Show line numbers
grep -n "pattern" file.txt
# Count matches
grep -c "pattern" file.txt
# Search recursively
grep -r "pattern" /path
# Search with file pattern
grep -r --include="*.js" "pattern" /path
# Show matching files only
grep -rl "pattern" /path
# Treffer invertieren (Zeilen, die NICHT übereinstimmen)
grep -v "pattern" file.txt
# Kontext anzeigen (3 Zeilen davor/danach)
grep -C 3 "pattern" file.txt
# 2 Zeilen davor anzeigen
grep -B 2 "pattern" file.txt
# 2 Zeilen danach anzeigen
grep -A 2 "pattern" file.txt
# Erweiterte Regex (Extended Regex)
grep -E "pattern1|pattern2" file.txt
# Perl-kompatible Regex
grep -P "\d{3}-\d{3}-\d{4}" file.txt
# Nur ganze Wörter finden
grep -w "word" file.txt
# Nur den passenden Teil anzeigen
grep -o "pattern" file.txt
# Ausgabe farblich hervorheben
grep --color=auto "pattern" file.txt
# Fehlermeldungen unterdrücken
grep -s "pattern" /path/*
Stream editor for text transformation.
# Erstes Vorkommen pro Zeile ersetzen
sed 's/old/new/' file.txt
# Alle Vorkommen ersetzen
sed 's/old/new/g' file.txt
# Groß-/Kleinschreibung beim Ersetzen ignorieren
sed 's/old/new/gi' file.txt
# Datei direkt bearbeiten (in-place)
sed -i 's/old/new/g' file.txt
# Backup erstellen, bevor bearbeitet wird
sed -i.bak 's/old/new/g' file.txt
# Passende Zeilen löschen
sed '/pattern/d' file.txt
# Spezifische Zeilennummern löschen
sed '5d' file.txt
# Zeilenbereich löschen
sed '5,10d' file.txt
# Leere Zeilen löschen
sed '/^$/d' file.txt
# Spezifische Zeilen ausgeben
sed -n '5p' file.txt
# Bereich ausgeben
sed -n '5,10p' file.txt
# Von einer Zeile bis zum Ende ausgeben
sed -n '5,$p' file.txt
# Mehrere Ersetzungen
sed -e 's/old/new/g' -e 's/foo/bar/g' file.txt
# Verwendung einer Befehlsdatei
sed -f commands.sed file.txt
Text processing and data extraction.
# Spezifische Spalten ausgeben
awk '{print $1, $3}' file.txt
# Alle Spalten ausgeben
awk '{print $0}' file.txt
# Ausgabe mit benutzerdefiniertem Trennzeichen
awk -F: '{print $1}' /etc/passwd
### Bedingungen
```bash
# Filter by condition
awk '$3 > 100 {print $0}' file.txt
# String comparison
awk '$1 == "error" {print $0}' logfile.txt
# Multiple conditions
awk '$3 > 100 && $3 < 200 {print $0}' file.txt
# NR - line number
awk '{print NR, $0}' file.txt
# NF - number of fields
awk '{print NF}' file.txt
# FILENAME - current file
awk '{print FILENAME, NR}' *.txt
# FS/OFS - field separators
awk 'BEGIN{FS=","; OFS="\t"} {print $1, $2}' file.csv
# Header and footer
awk 'BEGIN {print "Header"} {print $0} END {print "Total:", NR}' file.txt
# Sum column
awk '{sum += $1} END {print sum}' file.txt
# Average
awk '{sum += $1; count++} END {print sum/count}' file.txt
Befehle aus der Standardeingabe erstellen und ausführen.
# Execute command for each input
find . -name "*.txt" | xargs rm
# With placeholder
find . -name "*.txt" | xargs -I {} mv {} /backup/
# Limit arguments per command
find . -name "*.txt" | xargs -n 1 rm
# Parallel execution
find . -name "*.txt" | xargs -P 4 -n 1 command
# Handle spaces in filenames
find . -name "*.txt" -print0 | xargs -0 rm
# Using null delimiter
find . -type f -print0 | xargs -0 ls -la
Sortieren und Duplikate entfernen.
# Sort alphabetically
sort file.txt
# Sort numerically
sort -n numbers.txt
# Reverse sort
sort -r file.txt
# Sort by column
sort -k2 file.txt
# Sort by multiple keys
sort -k1,1 -k2,2n file.txt
# Unique sort
sort -u file.txt
# Remove consecutive duplicates
uniq file.txt
# Show count of duplicates
uniq -c file.txt
# Show only duplicates
uniq -d file.txt
# Show only unique
uniq -u file.txt
Text extrahieren und transformieren.
# Extract columns by position
cut -c1-10 file.txt
# Extract by delimiter
cut -d: -f1,3 file.txt
# Extract multiple fields
cut -d, -f2-4 file.csv
# Complement (exclude)
cut -d: -f1 --complement file.txt
# Convert to uppercase
tr 'a-z' 'A-Z' < file.txt
# Delete characters
tr -d '0-9' < file.txt
# Squeeze repeated characters
tr -s ' ' < file.txt
# Replace newline with space
tr '\n' ' ' < file.txt
Dateiteile und Statistiken anzeigen.
# First 10 lines
head file.txt
# First N lines
head -n 20 file.txt
# Last 10 lines
tail file.txt
# Last N lines
tail -n 20 file.txt
# Follow file updates
tail -f logfile.txt
# Lines 11-20
head -n 20 file.txt | tail -n 10
# Count lines
wc -l file.txt
# Count words
wc -w file.txt
# Count characters
wc -c file.txt
# All statistics
wc file.txt
Praxisbeispiele für Pipelines.
# Find unique IPs from access log
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head
# Count errors by hour
grep "ERROR" app.log | awk '{print substr($2,1,2)}' | sort | uniq -c
# Find slow requests
awk '$5 > 1000 {print $0}' access.log | sort -k5 -rn | head -10
# Find and delete old logs
find /var/log -name "*.log" -mtime +30 -exec rm {} \;
# Find large files
find . -type f -size +100M -exec ls -lh {} \;
# Count files by extension
find . -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn
# Extract emails from file
grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' file.txt
# CSV to TSV
tr ',' '\t' < file.csv > file.tsv
# Remove duplicate lines keeping order
awk '!seen[$0]++' file.txt
| Tool | Zweck | Wichtige Flags |
|---|---|---|
| find | Dateien suchen | -name, -type, -size, -mtime, -exec |
| grep | Text suchen | -r, -i, -n, -v, -E, -c |
| sed | Streams bearbeiten | s///g, -i, /d, -n |
| awk | Daten verarbeiten | -F, $N, NR, NF, BEGIN/END |
| xargs | Befehle aufbauen | -I, -n, -P, -0 |
| sort | Zeilen sortieren | -n, -r, -k, -u |
| uniq | Duplikate entfernen | -c, -d, -u |
| cut | Spalten extrahieren | -d, -f, -c |
| tr | Zeichen transformieren | -d, -s |
| head | Erste Zeilen | -n |
| tail | Letzte Zeilen | -n, -f |
| wc | Zählen | -l, -w, -c |
# Use grep before awk for speed
grep "pattern" file | awk '{print $1}'
# Use LC_ALL=C for faster sorting
LC_ALL=C sort largefile.txt
# Parallel xargs for multi-core
find . -type f | xargs -P 8 -n 1 command
# Find and replace in multiple files
grep -rl "oldtext" . | xargs sed -i 's/oldtext/newtext/g'
# Monitor log in real-time
tail -f /var/log/app.log | grep --line-buffered "ERROR"
# Extract column and get unique values
awk -F, '{print $2}' data.csv | sort -u
# Test sed before applying
sed 's/old/new/g' file.txt | head
# Dry-run find delete
find . -name "*.tmp" -print # Add -delete after verifying
# Verbose xargs
echo "file1 file2" | xargs -t rm