小言_互联网的博客

【Linux】一步一步学Linux——sh命令(225)

387人阅读  评论(0)

00. 目录

01. 命令概述

sh命令是shell命令语言解释器,执行命令从标准输入读取或从一个文件中读取。通过用户输入命令,和内核进行沟通!Bourne Again Shell (即bash)是自由软件基金会(GNU)开发的一个Shell,它是Linux系统中一个默认的Shell。Bash不但与Bourne Shell兼容,还继承了C Shell、Korn Shell等优点。

02. 命令格式

用法:sh [选项] [参数]

03. 常用选项

-c string:命令从-c后的字符串读取。
-i:实现脚本交互。
-n:进行shell脚本的语法检查。
-x:实现shell脚本逐条语句的跟踪。

04. 参考示例

4.1 bash命令的符号链接

[deng@localhost ~]$ ls -l /bin/sh
lrwxrwxrwx. 1 root root 4 11月  8 2018 /bin/sh -> bash
[deng@localhost ~]$ 

4.2 检查脚本是否正确,并不执行

[deng@localhost ~]$ sh -n test.sh 
[deng@localhost ~]$ 

4.3 执行脚本,输出执行过程

[deng@localhost ~]$ sh -x test.sh 
+ printf '%-10s %-8s %-4s\n' 姓名 性别 体重kg
姓名     性别   体重kg
+ printf '%-10s %-8s %-4.2f\n' 郭靖 男 66.1234
郭靖     男      66.12
+ printf '%-10s %-8s %-4.2f\n' 杨过 男 48.6543
杨过     男      48.65
+ printf '%-10s %-8s %-4.2f\n' 郭芙 女 47.9876
郭芙     女      47.99
[deng@localhost ~]$ 

05. 附录

参考:【Linux】一步一步学Linux系列教程汇总


转载:https://blog.csdn.net/dengjin20104042056/article/details/100937615
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场