Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
YouTube Security VideosNutanix advances legacy and AI app management with AMD(01.10.2026 um 16:00 Uhr)
•
YouTube Security VideosPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••••
Videos & KonferenzenPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••
Sicherheitslücken (CVE)USN-8857-1: KCoreAddons vulnerability(01.10.2026 um 12:48 Uhr)
•••
YouTube Security VideosNutanix advances legacy and AI app management with AMD(01.10.2026 um 16:00 Uhr)
•
YouTube Security VideosPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••••
Videos & KonferenzenPC-WELT: 32 TB SSD-Speicher in der HMX 6!(01.10.2026 um 16:15 Uhr)
••
Sicherheitslücken (CVE)USN-8857-1: KCoreAddons vulnerability(01.10.2026 um 12:48 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

AWK Cheat Sheet

What is AWK? awk is a powerful text-processing tool in Linux used to manipulate and analyze text files by processing patterns and performing actions. Basic…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!




What is AWK?



awk is a powerful text-processing tool in Linux used to manipulate and analyze text files by processing patterns and performing actions.









Basic Syntax







awk 'pattern {action}' file









  • pattern: The condition to match (optional).


  • action: Commands to execute on matching lines (optional).


  • file: The file to process.









Common Examples






1. Print All Lines







awk '{print}' file.txt








  • Outputs all lines in file.txt.






2. Print Specific Columns






 awk '{print $1, $3}' file.txt








  • Prints the 1st and 3rd columns.






3. Match a Pattern







awk '/error/ {print}' log.txt








  • Prints lines containing the word error.






4. Conditional Filtering







awk '$3 > 100 {print $1, $3}' data.txt








  • Prints rows where the 3rd column is greater than 100.






5. Add or Modify Columns







awk '{print $1, $2, $2 + $3}' data.txt








  • Adds a column with the sum of the 2nd and 3rd columns.






6. Count Matching Lines







awk '/pattern/ {count++} END {print count}' file.txt








  • Counts and prints lines matching pattern.






7. Format Output







awk '{printf "Name: %s, Age: %d\n", $1, $2}' names.txt








  • Formats and prints fields with a custom output.






8. Use Field Separator







awk -F ':' '{print $1, $NF}' /etc/passwd








  • Uses : as a separator and prints the 1st and last columns.









Key Concepts




































Symbol Meaning

$1, $2
Represents the 1st, 2nd columns (fields).
NR Line number (e.g., NR == 5 matches line 5).
NF Total number of fields in a line.
FS Field Separator (-F or FS=",").
BEGIN Executes before processing lines.
END Executes after processing all lines.








Advanced Examples









awk '{print NR, $0}' file.txt








  • Prints line numbers alongside the content.






Find Maximum in a Column







awk '$3 > max {max = $3} END {print max}' data.txt








  • Finds and prints the maximum value in the 3rd column.






Sum a Column







awk '{sum += $3} END {print sum}' data.txt








  • Sums up all values in the 3rd column.






Filter by Field Count







awk 'NF == 3 {print}' file.txt








  • Prints lines with exactly 3 fields.









Practice Data



Create a sample.txt to test commands:





John 25 500
Mary 30 600
Alex 28 450













Tips




  • Test commands with awk on small files before applying to large ones.

  • Combine with other commands like grep or sed for complex workflows.

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

Bedrohungsgraph · ATT&CK-Mapping · Exploit-Belege
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten AWK Cheat Sheet

Thematisch verwandte Begriffe: Cheat, Sheet · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag