Pages

Tuesday, June 21, 2011

How to determine if a file is in your shell search path

If you ever had the need to determine if a file is in your search path, the following Bash function does the job.

is_in_search_path ()
{
    file="$1"
    if ! type "$file" >/dev/null 2>&1; then
        return 1
    fi
    return 0
}

No comments:

Post a Comment