CARBON 2020-05-26
查看内置变量:set、env、printenv
赋值时,等于号两边不能有空格。变量名对大小写敏感
a=b # a的值为字符串“b”
myhome="/home/v/vivek"
NOW=$(date) # $() 执行命令 将结果赋给变量
NOW=`date` # 反引号执行命令 将结果赋给变量
s=‘abc‘ s=$s‘def‘ #字符串拼接
echo -n “abc” 不换行输出
echo "$HOME"
echo "${HOME}work"
echo ${a=c} # a为空 则给a默认值"c" 否则保持原样
echo "*** Run time: $(date +"%d-%m-%Y") @ $(hostname)"
echo /etc/*.conf
echo $(( 5 + 2 )) echo $(( 5 > 12 )) echo $(( 5 == 10 ))
printf "$PATH\n"
printf "The path is set to %s\n" $PATH
计算
echo $[1+1] # 方括号里执行算术运算 不支持浮点数
bc是计算器命令 可计算浮点数
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh
test-f /etc/resolv.conf &&echo"File /etc/resolv.conf found."||echo"File /etc/resolv.conf not found."