cancel
Showing results for 
Search instead for 
Did you mean: 

Conbine operator with test

SOLVED
Go to solution
Leo The Cat
Regular Advisor

Conbine operator with test

Hi

I have:

if ! test -d $rep_backup; then


how to say
If $rep_backup is not a directory or is not a symbolic link ; then

Bests Regards
Den
4 REPLIES
Ivan Ferreira
Honored Contributor
Solution

Re: Conbine operator with test

There are differents ways to do it:

if [ ! -d $rep_backup ] && [ ! -L $rep_backup ]
then
action...
fi
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: Conbine operator with test

Hi Den:

# [ -d $rep_backup -o -h $rep_backup ] && echo "is a dir or symlink" || echo "ok"

That is, if the variable represents a directory or a symbolic link, the test is true otherwise false.

Regards!

...JRF...
Leo The Cat
Regular Advisor

Re: Conbine operator with test

Thanks Guys
Kind Regards
Den
Dennis Handly
Acclaimed Contributor

Re: Conbine operator with test

You can also simplify Ivan's and reverse the sense of JRF's by:
if [ ! -d $rep_backup -a ! -L $rep_backup ]; then