LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash test -a ! -e (https://www.linuxquestions.org/questions/linux-newbie-8/bash-test-a-e-4175586332/)

vincix 08-05-2016 03:50 AM

bash test -a ! -e
 
So, I'm trying to understand the following syntax which seems contradictory to me:

linkchk () {
for element in $1/*; do
[ -h "$element" -a ! -e "$element" ] && echo "$element"
[ -d "$element" ] && linkchk $element
# Of course, '-h' tests for symbolic link, '-d' for directory.
done

Doesn't -a and -e mean the same thing? It seems as though it were saying that $element should and should not exist at the same time.

source:
http://tldp.org/LDP/abs/html/

chrism01 08-05-2016 05:06 AM

In this context '-a' is logical 'and' see http://tldp.org/LDP/abs/html/comparison-ops.html
Prev page there shows the old defn of '-a' is deprecated and that page is old itself ... ;)

vincix 08-05-2016 06:46 AM

I did read about it, but I didn't think it was out of use. There are many deprecated arguments, syntax structures, etc. that are deprecated, but they can still be used. So I didn't know about -a meaning 'and'. Indeed, I must have missed the definition of -a as a logical "and".

Thank you.


All times are GMT -5. The time now is 06:12 PM.