linux shell 内建命令,什么是Bash Shell的内建(build in)命令

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 ~]#0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Learning Linux Shell Scripting 2nd Edition pdf Break through the practice of writing tedious code with shell scripts Key Features Learn to impeccably build shell scripts and develop advanced applications Create smart solutions by writing and debugging scripts A step-by-step tutorial to automate routine tasks by developing scripts Book Description Linux is the most powerful and universally adopted OS. Shell is a program that gives the user direct interaction with the operating system. Scripts are collections of commands that are stored in a file. The shell reads this file and acts on commands as if they were typed on the keyboard. Learning Linux Shell Scripting covers Bash, GNU Bourne Again Shell, preparing you to work in the exciting world of Linux shell scripting. CentOS is a popular rpm-based stable and secured Linux distribution. Therefore, we have used CentOS distribution instead of Ubuntu distribution. Linux Shell Scripting is independent of Linux distributions, but we have covered both types of distros. We start with an introduction to the Shell environment and basic commands used. Next, we explore process management in Linux OS, real-world essentials such as debugging and perform Shell arithmetic fluently. You'll then take a step ahead and learn new and advanced topics in Shell scripting, such as decision making, starting up a system, and customizing a Linux environment. You will also learn about grep, stream editor, and AWK, which are very powerful text filters and editors. Finally, you'll get to grips with taking backup, using other language scripts in Shell Scripts as well as automating database administration tasks for MySQL and Oracle. By the end of this book, you will be able to confidently use your own shell scripts in the real world. What you will learn Familiarize yourself with the various text filtering tools available in Linux Understand expressions and variables and how to use them practically Automate decision-making and save a lot of time

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值