Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Korn Shell and arithemetic
Ryan,
He's using a in-line rediriection to supply input to bc, an external = program.
bc << __EOF__
means read everything from stdin as input to the 'bc' program, until you =
encounter __EOF__.
^J is a linefeed,
1.2 > 1.0 is the expression to be evaluated by 'bc',
^J, another line feed,=20
__EOF__ is the end of input to 'bc'.
Now that entire thing is enclosed in backquotes (`). That means that =
the output of the program, which would normally go to stdout, is return =
to the shell as a literal. That literal is enclosed in double quotes =
("), and
=3D "1" is compared to "1".
So, bc returns 1 if the expression is true and 0 if the expression is = false.
Note, however, that it appears the GNU version of bc is required, the =
standard bc on Solaris 8 does this:
SQL> !bc
1.2 > 1.0
syntax error on line 1, teletype
Hope that helps,
-Mark
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org]On Behalf Of
ryan.gaffuri_at_comcast.net
Sent: Wednesday, June 23, 2004 1:57 PM
To: oracle-l_at_freelists.org
Subject: OT: Korn Shell and arithemetic
Tim,=20
what does this syntax mean?=20
$ if [[ "`bc << __EOF__^J1.2 > 1.0^J__EOF__`" =3D "1" ]]
> then > echo yes > else echo no > fi
$ if [[ "`bc << __EOF__^J1.2 > 1.3^J__EOF__`" =3D "1" ]]
> then > echo yes > else echo no > fi ----------------------------------------------------------------Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html ----------------------------------------------------------------- ---------------------------------------------------------------- Please see the official ORACLE-L FAQ: http://www.orafaq.com ---------------------------------------------------------------- To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line. -- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Wed Jun 23 2004 - 13:21:26 CDT