在这个程序中我没有使用-f
这个语句。在这个声明中使用这个-f是什么?
if [ -f $file ]
我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
;;
'-f'检查是否存在该文件(并且它是一个常规文件) – Cheery 2014-10-06 18:08:51
@Cheery否,'-f'测试该文件是否是常规文件。 '-e'测试是否存在。 http://tldp.org/LDP/abs/html/fto.html – 2014-10-06 18:10:06
@BaconBits ['-f'测试*文件的存在性和规律性](http://www.tldp.org /LDP/Bash-Beginners-Guide/html/sect_07_01.html)。 – admdrew 2014-10-06 18:11:11