【发布时间】:2018-03-20 09:08:02
【问题描述】:
我的环境是:
- CentOS 6.9
- Ubuntu 16.04 LTS
GNU coreutils 8.4 具有使用-f 选项检查文件的测试命令。
man test 显示
-f FILE FILE exists and is a regular file
“常规文件”的定义对我来说是模棱两可的。
在终端上,我做到了
$ touch afile
$ ln -fs afile LN-FILE
然后,我执行了以下脚本 (check_file_exist_180320_exec)
#!/usr/bin/env bash
if [ -e LN-file ]
then
echo "file exists [-e]"
fi
if [ -f LN-file ]
then
echo "file exists [-f]"
fi
对于 CentOS 和 Ubuntu,对于符号链接文件 (LN-FILE) 都显示 -e 和 -f。
但是,ls -l 返回 LN-FILE 文件的 l:symbolik link(不是 -:regular file)标识符。
(见https://linuxconfig.org/identifying-file-types-in-linux)
另一方面,我发现以下内容, Difference between if -e and if -f
常规文件不是目录/符号链接/套接字/设备等。
于 2012 年 4 月 18 日 7:10 回答
jman
我应该检查“常规文件”(对于 CentOS 和 Ubuntu)的参考是什么?
【问题讨论】: