-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, Jun 22, 2006 at 10:15:22PM -0700, Durai raj wrote:
> Hi All,
>
> How to specify the precedence in the if/while loop?
> In C,
>
> if( i<j && (j>k || k<i) )
One uses -lt (less than) and -gt (greater than)
(You can look at man(1) test and of course, man sh.)
The test command is represented by [ ]. You need white space between the
bracket and what you write, for example
if [ a -gt b ]; then
do something
if [a -gt b] won't work.
You can use && and || for the and and the or.
So,
if [ i -gt j ] && [ j -gt k ] || [ k -lt i ];
then
do something.
Also, of course, there's alway another way--you can use -a for and and
- -o for or. In this case, it goes in the same bracket, eg
if [ a -gt b -a j -gt k -o k -lt i ]; then
do something
I'm being lazy here. As all these letters (a, b, j k and i are
variables and each one should probably be written "${a}" "${b}" etc, in
quotes as shown.
if [ "${a}" -gt "${b}" -a "${j}" -gt "${k}" ];
- --
Scott Robbins
PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6
Giles: Alright. I'll just jump into my time machine, go back to
the 12th century and ask the vampires to postpone their ancient
prophecy for a few days while you take in dinner and a show.
Buffy: Okay, at this point you're abusing sarcasm.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (FreeBSD)
iD8DBQFEm5J3+lTVdes0Z9YRArtPAKCdcJgKwTNgUlRGaufKw16+HDB6RgCeItUi
EAvQmB3d0qRYh/PJHw5bH1c=
=fOBJ
-----END PGP SIGNATURE-----
------------------------ Yahoo! Groups Sponsor --------------------~-->
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/0XFolB/TM
--------------------------------------------------------------------~->
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/