zhufeng518 发表于 2018-8-29 08:09:24

1.2-shell结构以及执行

  shell是按照脚本命令,顺序执行。
  #!/bin/bash或#!/bin/sh            /bin/sh是/bin/bash的软链接
  ##描述信息
  ls /etc/
  echo "this is a test script"
  wq保存退出,文件名为test.sh   不一定要.sh结尾,主要是为了区别和维护。
  2种执行方法:
  1:bash test.sh    或sh test.sh
  bash -x test.sh-x用来跟踪脚本执行过程中的状态,利于排错。
  2:chmod a+x test.sh      给文件赋予执行权限
  ./test.sh   或绝对路径 /root/test.sh

页: [1]
查看完整版本: 1.2-shell结构以及执行