Anything goes

random and perhaps useful information

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
}
Posted by tsengf at 12:06 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Search This Blog

Pages

  • Main blog
  • About this blog
  • Contact me

Popular Posts

  • DD-WRT on Belkin Share Max N300 (F7D7301)
  • DD-WRT client bridge mode
  • Installing SSH server in Cygwin on Windows 7
  • Install linux using PXE boot with tftp hosted on Windows
  • Configure bridge mode on the 2Wire 2701HG-B Gateway
  • How do I remove .nfs files?
  • Installing sendmail in Cygwin
  • Send Email from the command line in Ubuntu 11.10
  • Convert a space-separated string into array in Bash
  • Play youtube audio from the command line on Raspberry Pi

Labels

android bmw c car cygwin ddwrt emacs freshtomato gmail htpc libreelec linux network openwrt otg pihole pizero politics raspberrypi raspbian repair shopping technology usb utility windows wrt x1
Powered by Blogger.