I have a BASH script that is looking for a hidden file in my home directory. When I specify the absolute path /home/user/.foo
in trying to find the file then the script will find it but if I use ~/.foo
then the script cannot find the file. Can someone explain why this is happening and what other way I can find the file. I want to be able to find the file on different user's home directory and not just my own.
Sorry for not providing the snippet of code but here it is
file="~/.foo"
[ -f $file ] && echo "foo exists!"
this however works
file="home/user/.foo"
[ -f $file ] && echo "foo exists!"