【Bash百宝箱】shell内建命令之help、type、let、logout
2016-09-23 18:03
417 查看
1、help
在shell中,内建(builtin)命令help,格式如下:help [-dms] [pattern]
help命令用于显示shell内建命令的帮助信息,如果指定了模式pattern,则只显示与模式匹配的命令的帮助信息,否则显示全部内建命令的帮助信息。选项“-d”用于显示命令的一个简短描述,“-m”以man page的格式来打印命令描述,否则以默认格式打印,“-s”用于显示命令的语法格式。
下面以help命令查看help命令本身:
$ help -d help help - Display information about builtin commands. $ help -s help help: help [-dms] [pattern ...] $ help -m help NAME help - Display information about builtin commands. SYNOPSIS help [-dms] [pattern ...] DESCRIPTION Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN is specified, gives detailed help on all commands matching PATTERN, otherwise the list of help topics is printed. Options: -d output short description for each topic -m display usage in pseudo-manpage format -s output only a short usage synopsis for each topic matching PATTERN Arguments: PATTERN Pattern specifiying a help topic Exit Status: Returns success unless PATTERN is not found or an invalid option is given. SEE ALSO bash(1) IMPLEMENTATION GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
2、type
在shell中,内建(builtin)命令type,格式如下:type [-aftpP] name [name ...]
type命令用于查找shell命令name的类型。选项“-t”用于显示name的类型,包括别名alias、shell保留字keyword、函数function、内建builtin和磁盘文件file。对于磁盘文件file来说,选项“-p”可显示命令name指定的磁盘文件名。选项“-P”强制在环境变量PATH中搜索命令name。如果多个地方都包括命令name,使用选项”-a“可以把它们全部打印出来,否则只显示第一个。选项”-f“的作用是试图不在函数和内建命令中查找name。
下面是type命令的几个用法:
$ type type type is a shell builtin $ type -t type builtin $ type pwd pwd is a shell builtin $ type -t pwd builtin $ type -a pwd pwd is a shell builtin pwd is /bin/pwd $ type -t top file $ type top top is /usr/bin/top $ foo() { echo "function foo"; } $ type foo foo is a function foo () { echo "function foo" } $ type -t foo function
3、let
在shell中,内建(builtin)命令let,格式如下:let arg [arg ...]
let命令用于对数学表达式arg求值,例子如下:
$ a=1 $ b=2 $ c=$a+$b $ echo $c 1+2 $ let d=$a+$b $ echo $d 3
4、logout
在shell中,内建(builtin)命令logout用于退出登录shell。在Linux中,shell分为登录login和非登录nonlogin两种,登录shell如常用的”/bin/bash“,非登录shell如”/usr/sbin/nologin“,登录shell是用户可以登录使用的,登录以后可以与计算机交互,非登录shell则没有这个功能,但有其特殊用途,Linux上各用户的shell默认登录状态可查看文件”/etc/passwd“。相关文章推荐
- 【Bash百宝箱】shell命令
- 【Bash百宝箱】shell内建命令之cd、getopts
- 【Bash百宝箱】shell历史命令(history)
- 【Bash百宝箱】shell内建命令之冒号
- 【Bash百宝箱】shell内建命令之declare、typeset、local
- Linux基础学习之bash shell内置命令----type
- 【Bash百宝箱】shell内建命令之read、readarray、mapfile
- 【Bash百宝箱】shell内建命令之break与continue
- 【Bash百宝箱】shell内建命令之alias与unalias
- 【Bash百宝箱】shell内建命令之pwd、readonly、return、shift
- 【Bash百宝箱】shell内建命令之echo、printf
- Bash Shell let命令
- 【Bash百宝箱】shell内建命令之eval、exec、exit、export
- 【Bash百宝箱】shell内建命令之test
- 【Bash百宝箱】shell内建命令之bind、enable、ulimit
- 【Bash百宝箱】shell内建命令之set、shopt
- 【Bash百宝箱】shell内建命令之echo、printf
- 【Bash百宝箱】shell内建命令之times、umask、unset
- 【Bash百宝箱】shell内建命令之hash
- 【Bash百宝箱】shell内建命令之句点与source