2

I am supporting two groups. I have one script, and I would like to keep it at one. I am having trouble with a test function:

convtype=./Sample*/
if [[ -n convtype ]]; then

where it runs fine for some users but not others. The one thing I've noticed is that for people running it from a PC either a value or Null string is returned depending on what is in the directory, so then my if statement will evaluate to true or false. For MAC users, it always evaluates to a string and therefore is always true.

if I change these two lines to:

 if [[ -d Sample*/ ]]; then

if works for the MAC users, but not the PC users.

I'm looking for either a way to tell which type of machine the script is being run from or a different way to generate/test the variable that will work regardless. Suggestions most appreciated.

Michele
  • 21
  • 1

1 Answers1

-1

If the goal is to test if a directory exists and both systems are running in bash then you can do this working solution found in this working example

if ls /path/to/your/files* 1> /dev/null 2>&1; then
    echo "files do exist"
else
    echo "files do not exist"
fi