我没有-f在本程序中使用此声明.
if [ -f $file ]
Run Code Online (Sandbox Code Playgroud)
我if知道为什么我们-f在这里使用?
这是整个计划:
case $ch in
1)
echo -e "\n This is File Create Operation"
echo -e "\n Please Enter File Name:"
read file
if [ -f $file ]
then
echo -e "\n File already existing!!!"
else
touch $file
echo -e "\n File Created!!!"
echo -e "\n Created File can be Checked From Following Table"
ls -t|head -n 15
fi
;;
Run Code Online (Sandbox Code Playgroud)
[通常既是别名,test也是内置的shell.[ something ]相当于test something
请参阅help [bash以了解bash builtin的版本,并man test了解非内置二进制文件/bin/test.
[ -f file ]如果文件存在且是常规文件,你会看到这是真的,否则为false(即只有file普通文件才返回0 )
| 归档时间: |
|
| 查看次数: |
72 次 |
| 最近记录: |