Nice little bash function for determining the meaning of error codes

Here’s a cool idea from Deadman.org | Advancing in the Bash shell:

err ()
{
    grep --recursive --color=auto --recursive -- "$@" /usr/include/*/errno.h
    if [ "${?}" != 0 ]; then
        echo "Not found."
    fi
}

Then you can do stuff like:

15:07 marca@shifter:~$ err 23
#define ENFILE          23              /* Too many open files in system */

Leave a Reply

Your email address will not be published. Required fields are marked *