I need to know what the value of [ -a . ] is

November 9, 2010 at 13:59:29
Specs: Linux Fedora 13
if [ -a . ]
then
echo "Yes."
else
echo "No."
fi

See More: I need to know what the value of [ -a . ] is

Report •

#1
November 9, 2010 at 22:41:35
The value of [ -a . ] is always true because -a is the and option of the test command. check out man test. [ -a . ] does not really make any sense. The . means the current directory so "and" current directory is always true.

-a is typically used something like this:

if [ -r file1 -a -r file2 ]
then
   echo "Yes"
else
   echo "No"
fi

Above if file1 has read permission "and" file2 has read permission, echo "Yes".

Let me know if you have any questions.


Report •
Related Solutions


Ask Question