首先要说明的是,不要使用which来进行判断,理由如下: 1.which非SHELL的内置命令,用起来比内置命令的开销大,并且非内置命令会依赖平台的实现,不同平台的实现可能不同. # type type type is a shell builtin # type command command is a shell builtin # type which which is hashed (/usr/bin/which) 2.很多系统的which并不设置退出时的返回值,即使要查找的命令不存在,
Linux命令众多,当不清楚一个命令的使用方法时,我们该怎样了解命令的属性和帮助? 1.用type命令了解一个命令的属性 [root@zejin240 testdir]# type cd cd is a shell builtin [root@zejin240 testdir]# type rm rm is aliased to `rm -i' [root@zejin240 testdir]# type mysql mysql is /opt/lamp/mysql/bin/mysql c