api: "YAML JSON TOON Database" version: 1.0.0 format: json dataset: slug: awk-reference title: "AWK Reference" description: "Essential AWK commands, built-in variables, and common patterns." category: "Unix Commands" category_slug: unix-commands tags: "unix,awk,text-processing,scripting" view_count: 0 data [8]{pattern,command,description}: "Print columns","awk '{print $1, $3}'","Print the 1st and 3rd fields of each line." "Field separator","awk -F: '{print $1}' /etc/passwd","Use colon as delimiter; print 1st field." "Built-in variables","NR, NF, FS, OFS, RS, ORS, FILENAME","NR=record number, NF=field count, FS=OFS=field sep, RS=record sep." "Conditional print","awk '$3 > 100 {print $1}'","Print $1 only when $3 exceeds 100." "Sum a column","awk '{sum += $2} END {print sum}'","Accumulate sum of column 2 and print at END." "Pattern matching","awk '/error/ {print}' log.txt","Print lines matching the regex /error/." Functions,"length(), sub(), gsub(), split(), systime()","Built-in string and time functions." "Multi-character FS","awk -v FS=\"\\t\" '{print $2}'","Set field separator to tab using -v flag."