Chinaunix首页 | 论坛 | 博客
  • 博客访问: 545250
  • 博文数量: 252
  • 博客积分: 1068
  • 博客等级: 少尉
  • 技术积分: 1775
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-05 21:33
文章分类

全部博文(252)

文章存档

2013年(21)

2012年(231)

分类:

2012-06-04 14:35:28

 

#!/bin/sh

checkForCmdInPath()
{
    var=$1

    OldIFS=$IFS
    IFS=":"

    for directory in $PATH    
    do    
        if [ -x $directory/${var##/*/} ]
        then
            echo "${var##/*/} found in $directory"
            return
        fi
    done

    echo "${var##/*/} not found"
    IFS=oldIFS
}

if [ $# -ne 1 ]
then
    echo "Usage: $0 command" >&2
    exit 1
fi    

checkForCmdInPath "$1"

exit 0


阅读(246) | 评论(0) | 转发(0) |
0

上一篇:mount

下一篇:实现String类的BIG_FOUR

给主人留下些什么吧!~~