I want to locate the error code (like 500,200,404) from the apache log file. the error code must be taken as input given by me, ( when I run the script it must prompt like
" please enter the error code here (404,500,200): ..... "
when I enter the error code, it must sort and show the word count of that particular error happened in that apache log. and ask me to specify a name to save the file.
I am new to script, what I tried is below.
read -p "Enter the error code : " CODE
#echo 'Your Error code is,HTTP/1.1"' $CODE
cat test.txt | grep 'HTTP/1.1" $CODE' | wc -l
'HTTP/1.1" 500' or 'HTTP/1.1" 200' is the actual word I want to search, because if I grep 500 only, there will be more output. (like there is any other 500 is there it also pop up, I need only the 'HTTP/1.1" "error code" ' (error code which I mention as input while prompting)