美文网首页程序员
shell命令分类

shell命令分类

作者: pysta | 来源:发表于2018-11-02 21:51 被阅读9次

linux的shell命令总共分为5中,alias,function,file,builtin,keyword。

alias就是别名,function就是自己创建的shell函数,file就是path路径里的一些二进制或者其他sh文件等挂在硬盘上的文件,keyword就是shell的关键字。

可以通过type -t command来查看,另外如果一个命令是file的话,可以通过type -p command查看该命令的绝对路径..。

关于一个命令的运行到底有没有开辟新的进程,我们可以通过一种方法查看,首先运行该命令,然后ps -elf | grep一下就可以了,可以肯定的是file类型的command肯定是在子进程中运行的,但是builtin就不好说了,我man type一下:

Shell builtin commands are commands that can be executed within the running shell's process.  Note that, in the case of csh(1) builtin commands, the command is executed in a sub-

     shell if it occurs as any component of a pipeline except the last.

     If a command specified to the shell contains a slash ``/'', the shell will not execute a builtin command, even if the last component of the specified command matches the name of

     a builtin command.  Thus, while specifying ``echo'' causes a builtin command to be executed under shells that support the echo builtin command, specifying ``/bin/echo'' or

     ``./echo'' does not.

上面说的很清楚,第一段的意思是builtin命令可以在当前shell中运行,但是在csh中,如果在使用管道的时候内建命令不是在最后面,就会在子进程中运行。第二段的意思是如果使用绝对路径或者相对路径使用命令,即使最终引用的命令和builtin命令一样,也会在子进程中运行,相当于file类型的了。

阿里云双十一云服务器拼团活动,已经打到最低价99元一年!有需要的可以考虑一波了!

https://m.aliyun.com/act/team1111/#/share?params=N.9g4CZ2TwSh.qilw7y0a

---------------------

作者:pysta

来源:CSDN

原文:https://blog.csdn.net/Yvlen/article/details/79254439

版权声明:本文为博主原创文章,转载请附上博文链接!

相关文章

  • shell命令分为内部命令和外部命令

    Shell命令分类 Shell命令分为两种: 1)自带的命令称为内置命令。内部命令本质是一个自带的函数,当shel...

  • shell命令分类

    linux的shell命令总共分为5中,alias,function,file,builtin,keyword。 ...

  • Bash命令执行

    bash命令执行 命令分类 首先,我们先来聊聊命令的分类吧!在shell中可执行的命令一共有两类,分别为内部命令和...

  • Shell编程、part1

    1.shell简介2. shell分类3. 查看shell4. 第一个shell脚本5. shell编程常用命令5...

  • linux命令初探

    linux命令分类:shell内部命令:一般是最常用最简单的指令如 cd ,type 在shell启动时载入内存s...

  • vim学习 09——shell命令

    vim学习 09——shell命令 执行 shell 命令 :!shell命令 : 可以执行 shell 命令。 ...

  • Git 零基础入门--Git Bash

    Git 工具分类 命令行Bash、Cmd、Power Shell,等 GUIGit GUI、Github Desk...

  • Linux-帮助与基本命令

    1.获取命令帮助 Linux中的命令按可分类shell内嵌命令、外部命令,获取命令帮助信息前需要区分命令类型。 1...

  • ADB常用命令集合

    基础命令 USB设备命令 文件传输命令 SHELL命令 adb shell pm命令 adb shell am命令...

  • Git工具基础

    1.1-Git 安装: Git 工具分类: 命令行: Bash、Cmd、Power Shell,等。 GUI: G...

网友评论

    本文标题:shell命令分类

    本文链接:https://www.haomeiwen.com/subject/hdlhxqtx.html