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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.