Skip to main content

Thread: bash: if santax help: [ X ] && [ Y ] || [ Z ]


how write in sh/bash

javascript/php:
code:
if ( 1 == 1 && ( 1==2 || 2==2 ) ) {  }
this closest can without breaking it:
code:
if [ 1 -eq 1 ] && [ 1 -eq 2 ] || [ 2 -eq 2 ];then  fi

edit: forget it, it's wrong. following posts explain why.. trying variations, may post corrected 1 later..

code:
if [[ 1 -eq 1 && 1 -eq 2 || 2 -eq 2 ]];then  fi
works me.

example :
code:
a=2; b=3; c=4; if [[ $a -eq 2 && $b -eq 2 || $c -eq 4 ]]; echo yes; fi
..change declared values or test values , see difference. works -
if (condition 1) , (condition2 or condition3), then go ahead..


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk bash: if santax help: [ X ] && [ Y ] || [ Z ]


Ubuntu

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP