关键词搜索

全站搜索
×
密码登录在这里
×
注册会员

已有账号? 请点击

忘记密码

已有账号? 请点击

使用其他方式登录

linux手册

linux bash命令–shell脚本解释器

bash 是一个为GNU计划编写的Unix shell。它的名字是一系列缩写:Bourne-Again Shell — 这是关于Bourne shell(sh)的一个双关语(Bourne again / born again)。

bash是大多数Linux系统以及Mac OS X默认的shell,它能运行于大多数类Unix风格的操作系统之上,甚至被移植到了Microsoft Windows上的Cygwin系统中,以实现Windows的POSIX虚拟接口。此外,它也被DJGPP项目移植到了MS-DOS上。

语法格式:bash [参数] [文件]

常用参数

-n 检测脚本是否正确,并不执行脚本
-x 执行脚本,输出执行过程
-c bash从字符串中读入命令,如果字符串后还有变量就被设定为从$0开始的位置参数

参考实例

使用-n参数检查脚本语法时候正确:

[root@linuxcool ~]# bash -n linuxcool.sh

使用-x参数执行linuxcool.sh脚本并输出执行过程:

[root@linuxcool ~]# bash -x linuxcool.sh 
 ifconfig
 eth0: flags=4163  mtu 1500
     inet 192.168.3.21  netmask 255.255.255.0  broadcast 192.168.3.255
     inet6 fe80::20c:29ff:fe73:4b2f  prefixlen 64  scopeid 0x20
     ether 00:0c:29:73:4b:2f  txqueuelen 1000  (Ethernet)
     RX packets 1175439  bytes 578279763 (551.4 MiB)
     RX errors 0  dropped 1574  overruns 0  frame 0
     TX packets 165889  bytes 54096266 (51.5 MiB)
     TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 

 lo: flags=73  mtu 65536
         inet 127.0.0.1  netmask 255.0.0.0
         inet6 ::1  prefixlen 128  scopeid 0x10
         loop  txqueuelen 1  (Local Loopback)
         RX packets 538814  bytes 310506969 (296.1 MiB)
         RX errors 0  dropped 0  overruns 0  frame 0
         TX packets 538814  bytes 310506969 (296.1 MiB)
         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
点击QQ咨询
开通会员
上传资源赚钱
返回顶部
×
  • 微信支付
  • 支付宝付款
扫码支付
微信扫码支付
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载