跳至主要内容

Bourne shell

Bourne shell(伯恩壳),或sh,是Version 7 Unix默认的Unix shell,替代执行文件同为sh的Thompson shell。它由AT&T贝尔实验室的史蒂夫·伯恩在1977年在Version 7 Unix中针对大学与学院发布的。它的二进制程序文件在大多数Unix系统上位于/bin/sh,在很多Unix版本中,它仍然是root的默认shell。

其concise(简洁),compact(紧凑),fast(高效),由AT&T编写,属于系统管理shell。

评论

此博客中的热门博文

Shell 文件包含

  和其他语言一样,Shell 也可以包含外部脚本。这样可以很方便的封装一些公用的代码作为一个独立的文件。 Shell 文件包含的语法格式如下: . filename # 注意点号(.)和文件名中间有一空格 或 source filename 实例 创建两个 shell 脚本文件。 test1.sh 代码如下: #!/bin/bash # author:菜鸟教程 # url:www.runoob.com url = "http://www.runoob.com" test2.sh 代码如下: #!/bin/bash # author:菜鸟教程 # url:www.runoob.com #使用 . 号来引用test1.sh 文件 . ./ test1 . sh # 或者使用以下包含文件代码 # source ./test1.sh echo "菜鸟教程官网地址:$url" 接下来,我们为 test2.sh 添加可执行权限并执行: $ chmod + x test2 . sh $ ./ test2 . sh 菜鸟教程官网地址: http : //www.runoob.com 注: 被包含的文件 test1.sh 不需要可执行权限。

通过curl获取http状态码

通过curl获取网页当前的http状态码 操作实例如下: bbq@DESKTOP - SOR0NVK MINGW64 / d / gits / plan9 ( main ) $ curl - o / dev / null - s - w "%{http_code}" https :// plan9 . cn 200 说明: -o  输出,定向到 /dev/null -s  静默模式,不显示过程 -w  格式化输出,相关说明可通过 curl --help -w 来查看 bbq@DESKTOP - SOR0NVK MINGW64 / d / gits / plan9 ( main ) $ curl -- help - w - w , -- write - out < format > Make curl display information on stdout after a completed transfer . The format is a string that may contain plain text mixed with any number of variables . The format can be specified as a literal "string" , or you can have curl read the format from a file with "@filename" and to tell curl to read the format from stdin you write "@-" . The variables present in the output format are substituted by the value or text that curl thinks fit , as described below . Al...

Shell 输入/输出重定向

  大多数 UNIX 系统命令从你的终端接受输入并将所产生的输出发送回​​到您的终端。一个命令通常从一个叫标准输入的地方读取输入,默认情况下,这恰好是你的终端。同样,一个命令通常将其输出写入到标准输出,默认情况下,这也是你的终端。 重定向命令列表如下: 命令 说明 command > file 将输出重定向到 file。 command < file 将输入重定向到 file。 command >> file 将输出以追加的方式重定向到 file。 n > file 将文件描述符为 n 的文件重定向到 file。 n >> file 将文件描述符为 n 的文件以追加的方式重定向到 file。 n >& m 将输出文件 m 和 n 合并。 n <& m 将输入文件 m 和 n 合并。 << tag 将开始标记 tag 和结束标记 tag 之间的内容作为输入。 需要注意的是文件描述符 0 通常是标准输入(STDIN),1 是标准输出(STDOUT),2 是标准错误输出(STDERR)。 输出重定向 重定向一般通过在命令间插入特定的符号来实现。特别的,这些符号的语法如下所示: command1 > file1 上面这个命令执行command1然后将输出的内容存入file1。 注意任何file1内的已经存在的内容将被新内容替代。如果要将新内容添加在文件末尾,请使用>>操作符。 实例 执行下面的 who 命令,它将命令的完整的输出重定向在用户文件中(users): $ who > users 执行后,并没有在终端输出信息,这是因为输出已被从默认的标准输出设备(终端)重定向到指定的文件。 你可以使用 cat 命令查看文件内容: $ cat users _mbsetupuser console Oct 31 17 : 35 tianqixin console Oct 31 17 : 35 tianqixin ttys000 Dec 1 11 : 33 输出重定向会覆盖文件内容,请看下面的例子: $ echo "菜鸟教程:www.runoob.com" > users $ cat users 菜鸟教程:...