Jump to content

BASH .. what am I doing wrong?


Recommended Posts

I can't get this simple bash script to work .. can someone please tell me what i am doing wrong?

 

LIST=$(ls "$1")

for item in ${LIST[@]}
  do
   if[ -d $1$item ] then
      echo "$1$item is a directory"
   else
     echo "$1$item is NOT a directory" 
   fi
done

 

if I replace the if statment with just an echo $1$item, it returns the correct value.

 

but when I run this script I get this ..

dir_mon_notify.sh: line 16: syntax error near unexpected token `fi'

dir_mon_notify.sh: line 16: `  fi'

 

no matter what I do, I can't get it to work .. any help would be great.

 

Link to comment
https://forums.phpfreaks.com/topic/217672-bash-what-am-i-doing-wrong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.