声明: name="zhangsan"
使用: echo ${name} || echo $name
只读: readonly name
删除: unset name
获取长度: echo ${#name}
colors=(red blue pink yellow)
echo ${colors[@]}
#!/bin/bash
userId="410221199411268412"
readonly userId
year=${userId:6:4}
programmingLanguage="Shell"
languageLen=${#programmingLanguage}
echo "userId:${userId},在${year}年出生"
echo "programming language:${programmingLanguage} length:${languageLen}"
echo "current script file:$0"
echo $((100/2))
if [ -f test.txt ]
then
[ -f test.txt ] && echo '-f true1'
else
touch test.txt
[ -f test.txt ] && echo '-f true2'
fi
# [ -d shell ] && echo '-d true1'
# mkdir shell
# [ -d shell ] && echo '-d true2'