解决问题
- test有几种写法
- [ -f 1.txt ] 为什么在[]前后必须有空格
写法
if [ -f 1.txt ];then echo "hello";fi
if [ -f 1.txt ];then
echo "hello"
fi
if [ -f 1.txt ];
then
echo "hello"
fi
if [ -f 1.txt ]
then echo "hello"
fi
if [ -f 1.txt]
then
echo "hello"
fi
总结
- [ -f 1.txt ] ‘[‘是命令名 ’-f 1.txt ]’是参数,参数是用空格分割的,这是一个命令
- if then后都是跟的命令
- ;和回车都可以分割命令,多个命令在一行要用;分割