Split the string "/etc/log/messages" by the delimiter "/" and take the 7th field, then search for the string "failed" and print the 6th field.
cut -d"/" -f7 /etc/log/messages | grep "failed" | awk '{print $6}'