脚本第一行一定是#!/bin/bash

1、脚本执行时输出到命令行  echo “this is me” 

               printf %s %c %d %f

2、脚本执行时从命令行读取输入read var    脚本内执行命令`ls -l “/boot”`

3、设置变量name=wu  使用变量${wu}  删除变量unset wu   只读变量readonly wu

4、定义数组namearray=("an" "bing" "cun")  使用变量${namearray[0]}

5、脚本参数:参数个数$#  第一个参数$1  脚本名$0  所有参数$*或者$@  当前进程ID: $$  退出状态$?  后台最后一个进程ID: $!

6、运算符:算术+-x/%  关系  布尔  逻辑  字符串  文件测试(-f -d -e -r -w -x)

7、定义函数fun(){}  使用函数fun  使用带参数函数fun v1 v2 v3

8、重定向command > file  command >>file  command < file  command > file 2>&1  0表示标准输入,1表示标准输出,2表示错误输出。/dev/null

9、包含文件. ./file    source ./file

相关文章:

  • 2022-12-23
  • 2021-10-31
  • 2021-11-01
  • 2021-09-16
  • 2022-12-23
  • 2021-07-15
  • 2022-02-04
  • 2021-08-04
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2021-12-08
  • 2021-11-28
  • 2021-12-24
  • 2022-12-23
  • 2022-02-27
相关资源
相似解决方案