如题 shell script 中 if [ $1 ] 和 if [ -a $1] 区别
来源:学生学帮网 编辑:学帮网 时间:2024/07/05 04:54:33
如题 shell script 中 if [ $1 ] 和 if [ -a $1] 区别
if [ $1 ] 判断参数是否存在
-bash-4.1$ sh one.sh
please para:
-bash-4.1$ sh one.sh testOne
para: testOne
-bash-4.1$ cat one.sh
#!/bin/bash
if [ $1 ]
then
echo "para: $1" #有参数testOne 输出此行
else
echo "please para:" #没有参数testOne 输出此行
fi
-bash-4.1$
if [ -a $1] 判断文件或目录是否存在,即$1变量上面对应的是testOne
-bash-4.1$ ls
one.sh te.sh testOne two.sh //此目录下,文件列表
-bash-4.1$ sh two.sh adf // 没有这个文件adf
no exist file: adf
-bash-4.1$ sh two.sh testOne // 有这个文件夹testOne
exist file : testOne
-bash-4.1$ cat two.sh //脚本内容
#!/bin/bash
if [ -a $1 ]
then
echo "exist file : $1"
else
echo "no exist file: $1"
fi
-bash-4.1$
-a现在一般情况下都会用-e来替换.
如题 shell script 中 if [ $1 ] 和 if [ -a $1] 区别
shell脚本中 if 判断时候-s是什么意思
shell脚本if [ $1
SCRIPT在代码中是什么意思
shell 中 if then语句中会跟着-ne -ge之类的语句是什么意思呢
shell 脚本中$$,$#,
How do I write a shell script to display a statement in dos?
shell
if you could see me now-------the script 空间链接
if you ever come back的歌词the script的
求The Script - If You Ever Come Back中英文歌词
ANSYS中分别用beam单元、shell单元、solid单元计算一根简支梁,计算精度有差异,原因是什么?如题
英语翻译A shell script is a scriptwritten for the shell,or command line interpreter(命令行解释器),of an operating system.[clarification needed]The shell is often considered a simpledomain-specific programming language.(领域专用语言) T
在shell里面,“%”、“#”、“*” 如${a%#.}、${a%%.*}、${a##.*}
shell中有没有substr函数啊?
sap2000建模中,shell 厚度 膜 弯曲
外贸面料英语中,DTM shell
bash shell中if [-f $2]和echo -e是什么意思看到很多判断语句都可以带参数的,有没有相关参数的大全或者解释?