jeudi 31 décembre 2020

bash check if a given file exists in a directory is failing on wildcard [duplicate]

FILE=*.tf
if [ -f "$FILE" ]; then
> echo "$FILE exists."
> else
> echo "$FILE does not exist."
> fi
does not exist.

The directory Im running this in has a file myfile.tf in it.

Im wondering why this isnt finding the myfile.tf file - could it be because im using the * asterisk wildcard ? What am I doing wrong here?

Thanks

Aucun commentaire:

Enregistrer un commentaire