The AWK command filters requests with a 404 status code using the following syntax:
awk '{count[$6]++} END {for (code in count) print code, count[code]}' server_logs.txt | sort -n
In this command:
$6refers to the sixth field in each line of the input, which typically contains the HTTP status code.count[$6]++increments the count for each occurrence of the status code found in the sixth field.END {for (code in count) print code, count[code]}executes after processing all lines, printing each status code and its corresponding count.| sort -nsorts the output numerically.
To specifically filter for 404 status codes, you can modify the command like this:
awk '$6 == "404" {print}' server_logs.txt
This command will print only the lines where the sixth field equals "404".
