检查一个目录中是否有某个文件,而不管里面的另一个目录 - linux ksh

Check if there's some file on a directory regardless of another directory inside - linux ksh

我正在尝试检查目录中是否有任何文件,但我需要它独立于可以或不能是另一个目录的事实。 我正在使用:

if [ -n "$(ls -A /unload/ebia 2>/dev/null)" ]
then
  Exists="Yes"
else
  Exists="No"
fi

echo "is any file inside $PATH ? $Exists."

如果 $PATH 上没有任何内容,它会说没有,如果里面有任何文件,它会说是(这是正确的),但是如果我在 $PATH 中创建一个目录,它会一直回答是,而不是没有文件。如何避免这种情况?

使用查找:

    if [ -n "$(find /unload/ebia/ -type f)" ]
    then
      Exists="Yes"
    else
      Exists="No"
    fi

发现-type f切换只搜索文件并跳过目录