Grep for lines in web logs

I want to find the unique url in a apache logs which got 404 error .

I can do something like

"cat apache.log|grep 404|awk '{print $2,$3}'|grep 404

this will give me say

/foo.html 404
/foo.html 404
/foo.html 404
/bar.html 404
/cat.html 404

However my output should only find unique results and should not give 3 instances of foo.html

It should look
/foo.html 404
/bar.html 404
/cat.html 404

Please try with the below

cat access_log | grep -R 404 | awk '{print $2, $3}' | sort | uniq -c | sort -n

try this then

sort -u apache.log|awk '/404/{print $2","$3}'

Great . It worked