1

The problem is that when I use this part of a script, it works fine on a linux environment and in the rest of the code it returns the list of files. However, when using CMDER (Full version) on Windows 10, it simply returns "no .txt files found". So no .txt files found in defined path even though I have 3 .txt files there. I even tried MobaXterm and got the same results.

path=$1

#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

Please note that I'm a beginner in shell scripting and really want to learn so any advice is greatly appreciated!

2 Answers 2

1

I fixed the problem by adding the following line at the end of user_profile inside the config folder

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

NOTE: there are other ways to fix it by this seemed to be the simplest way for me.

2
  • I am honestly confused as to what your solution has to do with the problem. Your script does not appear to use git. Commented Jul 1, 2020 at 8:37
  • I think it was related to the find command "find $path -type f -name '*.txt'". It was not finding .txt files before I added that part to user_profile. As I mentioned before, on a fully setup linux environment, it was running fine. It was just a simple path issue in the end I guess
    – user13843898
    Commented Jul 1, 2020 at 14:21
0

Are you sure your script works at all? Equality operator in Bash is ==, not =.

See String comparison in Bash

1
  • Yes it works. My fault for not being clear, but its part of a script to list .txt files of specific path. Its not the entire script but I'm pretty sure this is where the problem lies.
    – user13843898
    Commented Jun 30, 2020 at 23:51