Bash Commands and Shell Scripts
为了考试准备一下吧
这门课对这个领域的知识教的太浅,考的却很难,必须要额外自学一点东西
Variables in Shell Scripts
首先是 Shell Scripts 中的变量概念: Shell Scripts 中的 变量只有一种类型 string
Define variable in shell scripts
对于一个变量赋值语句 a=xxx,xxx 必须是字符串 string
-
xxx是单引号括起来的a='hello': 单引号中的内容不支持 variable substitution -
xxx是双引号括起来的a="$b": 双引号中的内容支持 variable substitution -
xxx是反引号括起来的反引号
` `与$()符号的作用已知
反引号中的内容是 bash command: 注意,所有 bash command 的 output 都是 string
Access variable in shell scripts
使用符号 $ 来访问变量
$a 可以视为将变量 a 中的字符串展开,即 variable substitution
Text Processing Command: grep, sed, awk and tr
文本处理一直是 shell script 出题的大头