1.命名规则
以字母或下划线开头,后面可以接任意长的字母,数字或下划线。
2.赋值
格式:
variable=value #当所赋的值含空格或将几个变量连接起来时需加双引号
eg:
fish@piniheaven:~$ var=hello;
fish@piniheaven:~$ var1=how;
fish@piniheaven:~$ var2="are you";
3.取出变量的值
格式:
$variable
eg:
fish@piniheaven:~$ var3="$var $var1 $var2";
4.简单的echo输出
用途:
产生Shell脚本的输出
格式:
echo [string...]
eg:
fish@piniheaven:~$ echo hello how are you
hello how are you
fish@piniheaven:~$ echo $var3; #$var3 见前面的定义
hello how are you
5.printf
功能:类似与C语言的printf()函数
格式:
printf format-string [arguments....]
eg:
fish@piniheaven:~$ printf "hello %s are %s\n" how you
hello how are you
以字母或下划线开头,后面可以接任意长的字母,数字或下划线。
2.赋值
格式:
variable=value #当所赋的值含空格或将几个变量连接起来时需加双引号
eg:
fish@piniheaven:~$ var=hello;
fish@piniheaven:~$ var1=how;
fish@piniheaven:~$ var2="are you";
3.取出变量的值
格式:
$variable
eg:
fish@piniheaven:~$ var3="$var $var1 $var2";
4.简单的echo输出
用途:
产生Shell脚本的输出
格式:
echo [string...]
eg:
fish@piniheaven:~$ echo hello how are you
hello how are you
fish@piniheaven:~$ echo $var3; #$var3 见前面的定义
hello how are you
5.printf
功能:类似与C语言的printf()函数
格式:
printf format-string [arguments....]
eg:
fish@piniheaven:~$ printf "hello %s are %s\n" how you
hello how are you