I'm fairly new to bash scripts, so this is probably a stupid syntax error, but why is this code not working?

for x in $(ls)
do
  if [ -d $x ]
  then
  echo $x
  fi
done

The separate for and if section work fine on their own, but this produces no output.

Edit
Report