Hi i am trying to set up an IF statement that says if FILE1 exists or FILE2 exists do a command. I am struggling to remember what i need to put in for the OR statement. i have the following
if [ -a $FILE1 (or?) -a $FILE2 ] then run my command fi
Would a | command work?
if [ -a $FILE1 -o -a $FILE2 ] then run my command fi
Google
What if, I want to achieve and condition in between?
I got the solution, you need to put -a.
Just for info, newer shells like bash and ksh allow more "usual" short circuit operator syntax of && and || so you can do things like
[[ -d file1 && -d file2 ]] || echo "Both files are not directories"
i.e. with && for AND, || for OR
Cheers ZB