Basic operations
Print the first column of a file
awk '{print $1}' file.txtPrint the second and third column of a file
awk '{print $2, $3}' file.txtPrint all lines that contain a specific word
awk '/word/ {print}' file.txtPrint the sum of the first column of a file
awk '{sum+=$1} END {print sum}' file.txtPrint the average of the first column of a file
awk '{sum+=$1; count++} END {print sum/count}' file.txtPrint the maximum value of the first column of a file
awk '{if($1>max) max=$1} END {print max}' file.txtPrint the minimum value of the first column of a file
awk '{if($1<min) min=$1} END {print min}' file.txtPrint the number of lines in a file
awk 'END {print NR}' file.txtPrint the number of fields in each line of a file
awk '{print NF}' file.txtPrint specific lines based on a condition
awk '$1 > 50 {print}' file.txt