Bash Shell 脚本未在 Windows 10 上使用 CMDER 查找文件,但在 Linux 上有效

Bash Shell Script is not finding files using CMDER on Windows 10 but works on Linux

问题是,当我使用脚本的这一部分时,它在 linux 环境中工作正常,而在其余代码中它是 returns 文件列表。然而,当在 Windows 10 上使用 CMDER(完整版)时,它只是 returns“找不到 .txt 文件”。因此,即使我在那里有 3 个 .txt 文件,也没有在定义的路径中找到 .txt 文件。我什至尝试了 MobaXterm 并得到了相同的结果。

path=

#files with read permission in path
count=`find $path -type f -name '*.txt' -perm /a=r`

# at least one file found
if [ "X${count}" = "X" ]
then
  echo 'no .txt files found'
  exit 1
fi

请注意,我是 shell 脚本编写的初学者,非常想学习,因此非常感谢任何建议!

您确定您的脚本完全有效吗? Bash 中的相等运算符是 ==,而不是 =

String comparison in Bash

我通过在配置文件夹 user_profile 的末尾添加以下行来解决问题

set "PATH=%GIT_INSTALL_ROOT%\usr\bin;%PATH%"

注意:还有其他方法可以解决这个问题,这对我来说似乎是最简单的方法。