fg_
fg_

Reputation: 59

Bash script can't find a file using a if statement with -e

I have a simple bash script that tries to find a folder, and if it can't find it, it gives an error. It gets a argument and tries to find a folder in the .local folder called menu. I have the folder, but it can't find it:

Permissions Links Size User Group Date Modified Name
drwxrwxrwx@     1    - lost lost  15 Jul 22:19  📂 menu

My code:

if [[ $1 == "edit" ]]
then
  if [[ $2 == "" ]]
  then
    echo "Error: You need to enter a playlist name."
    exit
  fi
  if [[ -e "~/.local/share/folder/$2/" ]]
  then
    $EDITOR ~/.local/share/folder/$2
  else
    echo "Error: No playlist called $2 exists."
  fi
fi

I'm running it with the argument edit menu. Output: Error: No playlist called menu exists.

Does anyone know what is wrong with this code?

Thanks.

This doesn't work using -f or -d too.

Upvotes: 1

Views: 35

Answers (0)

Related Questions