从今天起在Ubuntu12.04下学习一下Shell编程。文字编辑器用的是gedit。
1 2 3 4 5 |
#!/bin/bash # 对变量赋值: a="hello world" #等号两边均不能有空格存在 # 打印变量a的值: echo "A is:" $a |
保存为文件test.sh,然后执行 chmod +x test.sh 使其可执行,最后在terminal中输入 ./test.sh执行该脚本。其输出结果如下
1 |
A is: hello world |