Linux:shell命令
-
Shell echo命令
-
显示普通字符串
echo "i am wsf" -
显示转义字符
echo "i\" am usf" -
显示变量
read name#相当于python中的input echo "${name} is a name" read -p "请输入您的名字:" names#提示 echo "${names} is a names" -
显示换行
echo -e "i am fine \n" echo " irt is finr" -
显示不换行
echo -e "ok \c" echo "i am fine" -
显示结果定向至文件
echo "i am ok" > myfile -
原样输出字符串,不进行转义或取变量(用单引号)
echo '$name\"' -
显示命令执行结果
echo `date`
-
-
Shell read命令

read a b c #使用空格分开 echo $a $b $c read -p "请输入您的年龄" age echo "您的年龄是:${age}" read -p "请输入您的年龄" -t 3 age echo echo "您的年龄是:${age}" read -p "请输入您的年龄" -s -t 5 age echo echo "您的年龄是:${age}" -
Shell printf命令
-
Shell test命令

a=5 b=3 if test $a = $b; then echo "两数相等" else echo "两数不相等" fi if test -z $a; then echo "字符串长度为0" else echo "字符串长度不为0" fi
if test -e ./demo.sh; then echo "存在" else echo "不存在" fi if test -w ./demo.sh; then echo "存在且可读" else echo "不存在或不可读" fi


















