View Single Post
  #8 (permalink)  
Old 07-02-2009, 01:35 PM
cfajohnson cfajohnson is offline
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 78
Thanks: 0
Thanked 14 Times in 14 Posts
Rep Power: 2
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by nixcraft View Post
How?
Code:
INPUT="this is a test.txt"
[ ! -f "$INPUT" ] && echo "No" || echo "Yes"
No
Code:
>"$INPUT"
[ ! -f "$INPUT" ] && echo "No" || echo "Yes"
Yes
And with empty
Code:
INPUT=""
 [ ! -f "$INPUT" ] && echo "No" || echo "Yes"
No

Tested on GNU bash, version 3.2.39.

Now try it the way you wrote the script, without quotes around $INPUT.

It will give you error messages.
Reply With Quote
The Following User Says Thank You to cfajohnson For This Useful Post:
nixcraft (07-02-2009)