This is what I have been trying and it is unsuccessful. If I wanted to check if a file exists in the ~/.example directory
FILE=$1
if [ -e $FILE ~/.example ]; then
echo "File exists"
else
echo "File does not exist"
fi
Late to the party here but a simple solution is to use -f
if [[ ! -f $FILE]]
then
echo "File does not exist"
fi
A few more examples here if you're curious
This should do:
FILE=$1
if [[ -e ~/.example/$FILE && ! -L ~/example/$FILE ]]; then
echo "File exists and not a symbolic link"
else
echo "File does not exist"
fi
It will tell you if $FILE exists in the .example directory ignoring symbolic links.
You can use this one too:
[[ -e ~/.example/$FILE && ! -L ~/example/$FILE ]] && echo "Exists" || echo "Doesn't Exist"
-e in the OP's question tests for anything with the right name, e.g. it could be a directory.
$FILE ~/.examplefile?