什么是Bash Shell的内建(build in)命令
2017-10-29 15:40
555 查看
原文链接: 点击打开链接
1.什么是build in命令:
shell内建命令是指bash(或其它版本)工具集中的命令。一般都会有一个与之同名的系统命令,比如bash中的echo命令与/bin/echo是两个不同的命令,尽管他们行为大体相仿。当在bash中键入一个命令时系统会先看他是否是一个内建命令,如果不是才会查看是否是系统命令或第三方工具。所以在bash中键入echo命令实际上执行bash工具集中的bash命令也就是内建命令,而不是/bin/echo这个系统命令。
2.内建命令与系统命令
内建命令要比系统论命令有比较高的执行效率。外部命令执行时往往需要fork出(产生出)一个子进程,而内建命令一般不用。下面(或许以后还会有)这一篇文章将介简bash的内建命令。
3.查看一个命令是系统命令还是内建命令:type
linuxidc@www.linuxidc.com:~/Documents
$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
linuxidc@www.linuxidc.com:~/Documents
$ type -a echo
echo is a shell builtin
echo is /bin/echo
可以看出,有些命令,echo和pwd同时是内建命令和系统命令。
4.常见命令的类型
[root@linuxidc ~]# type -a cd
cd is a shell builtin
[root@linuxidc ~]# type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
[root@linuxidc ~]# type -a time
time is a shell keyword
time is /usr/bin/time
[root@linuxidc ~]# type -a date
date is /bin/date
[root@linuxidc ~]# type -a which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
which is /usr/bin/which
[root@linuxidc ~]# type -a whereis
whereis is /usr/bin/whereis
[root@linuxidc ~]# type -a whatis
whatis is /usr/bin/whatis
[root@linuxidc ~]# type -a function
function is a shell keyword
[root@linuxidc ~]# type -a ls
ls is aliased to `ls --color=tty'
ls is /bin/ls
[root@linuxidc ~]# type -a ll
ll is aliased to `ls -l --color=tty'
[root@linuxidc ~]# type -a echo
echo is a shell builtin
echo is /bin/echo
[root@linuxidc ~]# type -a bulitin
-bash: type: bulitin: not found
[root@linuxidc ~]# type -a builtin
builtin is a shell builtin
[root@linuxidc ~]# type -a keyword
-bash: type: keyword: not found
[root@linuxidc ~]# type -a command
command is a shell builtin
[root@linuxidc ~]# type -a alias
alias is a shell builtin
[root@linuxidc ~]# type -a grep
grep is /bin/grep
[root@linuxidc ~]#
1.什么是build in命令:
shell内建命令是指bash(或其它版本)工具集中的命令。一般都会有一个与之同名的系统命令,比如bash中的echo命令与/bin/echo是两个不同的命令,尽管他们行为大体相仿。当在bash中键入一个命令时系统会先看他是否是一个内建命令,如果不是才会查看是否是系统命令或第三方工具。所以在bash中键入echo命令实际上执行bash工具集中的bash命令也就是内建命令,而不是/bin/echo这个系统命令。
2.内建命令与系统命令
内建命令要比系统论命令有比较高的执行效率。外部命令执行时往往需要fork出(产生出)一个子进程,而内建命令一般不用。下面(或许以后还会有)这一篇文章将介简bash的内建命令。
3.查看一个命令是系统命令还是内建命令:type
linuxidc@www.linuxidc.com:~/Documents
$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
linuxidc@www.linuxidc.com:~/Documents
$ type -a echo
echo is a shell builtin
echo is /bin/echo
可以看出,有些命令,echo和pwd同时是内建命令和系统命令。
4.常见命令的类型
[root@linuxidc ~]# type -a cd
cd is a shell builtin
[root@linuxidc ~]# type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
[root@linuxidc ~]# type -a time
time is a shell keyword
time is /usr/bin/time
[root@linuxidc ~]# type -a date
date is /bin/date
[root@linuxidc ~]# type -a which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
which is /usr/bin/which
[root@linuxidc ~]# type -a whereis
whereis is /usr/bin/whereis
[root@linuxidc ~]# type -a whatis
whatis is /usr/bin/whatis
[root@linuxidc ~]# type -a function
function is a shell keyword
[root@linuxidc ~]# type -a ls
ls is aliased to `ls --color=tty'
ls is /bin/ls
[root@linuxidc ~]# type -a ll
ll is aliased to `ls -l --color=tty'
[root@linuxidc ~]# type -a echo
echo is a shell builtin
echo is /bin/echo
[root@linuxidc ~]# type -a bulitin
-bash: type: bulitin: not found
[root@linuxidc ~]# type -a builtin
builtin is a shell builtin
[root@linuxidc ~]# type -a keyword
-bash: type: keyword: not found
[root@linuxidc ~]# type -a command
command is a shell builtin
[root@linuxidc ~]# type -a alias
alias is a shell builtin
[root@linuxidc ~]# type -a grep
grep is /bin/grep
[root@linuxidc ~]#
相关文章推荐
- 什么是bash shell的内建(build in)命令
- 什么是bash shell的内建(build in)命令
- 什么是Bash Shell的内建(build in)命令
- 什么是Bash Shell的内建(build in)命令
- 编译用户版软件(User Build)的命令是什么
- .NET Core的“dotnet restore”、“dotnet build”和“dotnet run”命令都是用来干什么的?
- Linux中显示一个文件最后几行的命令是什么?
- Using Flex Build-in Print Function(Flex 打印功能系列转载)
- 为perforce添加nothave命令,查找尚未添加到depot中的文件(in Ruby)
- yum是什么?(linux命令)
- [Tutorial] How to build a GUI in ROS with Qt / C++?
- 如何利用QT在terminal终端执行ROS系统中的roslaunch命令(How to launch a roslaunch in Qt with a terminal (GUI) )
- VI用什么命令到文件头和文件尾?
- 命令 routerA(config) #line cons 0 允许你接下来做什么?
- 导入工程报错activity什么的都不认识了The project was not built since its build path is incomplete.
- Shell简介:什么是Shell,Shell命令的两种执行方式
- 一、Shell简介:什么是Shell,Shell命令的两种执行方式
- CMD用什么命令可以删除服务?
- liunx立即关机命令是什么?