Tim Alberts
2008-Mar-31 20:37 UTC
[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: talberts.vcf Type: text/x-vcard Size: 337 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20080331/1e64dfca/attachment-0001.vcf>
Marko A. Jennings
2008-Mar-31 20:43 UTC
[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?
On Mon, March 31, 2008 4:37 pm, 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 $?* > 10 = exists 1 = does not exist
Rudi Ahlers
2008-Mar-31 20:47 UTC
[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?
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
Stephen Harris
2008-Mar-31 21:11 UTC
[CentOS] Why does 'test -f' and 'test -e' return true on a (hidden) file that doesn't exist?
On Mon, Mar 31, 2008 at 01:37:01PM -0700, 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"0" means true % test 1 == 1 ; echo $? 0 % test 1 == 2 ; echo $? 1 % test 1 == 1 && echo good good (BTW, putting * around lines you type is REALLY bad quoting style) -- rgds Stephen