I'm using awk to write a bash script that outputs the count of error codes ranging from 400 - 500 that appear in a text file called output.txt
awk '($9 >= 400)' output.txt | awk '{print $9}' | sort | uniq -c
The output of the above is:
12 400
11 401
55 403
91 404
41 500
How do I add the first column together using bash so that in the example above, I get 210 instead of the above output... (12 + 11 + 55 + 91 + 41 = 210)
And if I wanted to input in a file via command line argument instead of output.txt how should I edit the script? I know that you use '$1' and '$2' to access command line arguments, but in this case how would it work considering I'm already using $9 in with awk
3and6you get36, when you add3and6you get9.