[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?

Mon Mar 31 20:47:35 UTC 2008
Rudi Ahlers <Rudi at SoftDux.com>

Tim Alberts wrote:
> Why does 'test -f' and 'test -e' return true on a (hidden) file that 
> doesn't exist?
>
> *> cat /home/talberts/.forward*
> cat: /home/talberts/.forward: No such file or directory
> *> test -f /home/talberts/.forward ;echo $?*
> 1
> *> test -e /home/talberts/.forward ;echo $?*
> 1
>
>
> _______________________________________________
>   
It doesn't:

[root at gandalf ~]# cat /tmp/.test1
test1
[root at gandalf ~]# test -f /tmp/.test1 ; echo $?*
0*
[root at gandalf ~]# test -f /tmp/.test1 ; echo $?
0

[root at gandalf ~]# cat /tmp/.test2
cat: /tmp/.test2: No such file or directory
[root at gandalf ~]# test -f /tmp/.test2 ; echo $?
1
[root at gandalf ~]# test -e /tmp/.test2 ; echo $?
1
[root at gandalf ~]#

-- 

Kind Regards
Rudi Ahlers
CEO, SoftDux

Web:   http://www.SoftDux.com
Check out my technical blog, http://blog.softdux.com for Linux or other technical stuff, or visit http://www.WebHostingTalk.co.za for Web Hosting stuff