在 bash 脚本中,要测试目录条目是否为文件夹,我们使用 -d ,
shopt -s dotglob nullglob # to include hidden fille
for entry in *
if [ -d "$entry" ]; then # regular directory, not hidden ones...
要测试文件,-f
if [ -f "$entry" ]; then # regular file, not hidden ones...
隐藏目录的属性是什么? , 和隐藏文件?
最佳答案
Hidden files / directories exist only by name convention in UNIX .他们的名字以点开头:
if [[ -d "${entry}" && "${entry}" =~ ^\. ]] ; then
echo "${entry} is a hidden folder"
fi
进一步(有趣)阅读:https://plus.google.com/u/0/+RobPikeTheHuman/posts/R58WgWwN9jp
关于linux - bash 隐藏目录和文件的测试属性是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44925369/