Nope, unless I missed what you trying to get at.
#!/bin/bash
if [$1 == '']; then
echo ''
echo "format is $0 'math equation'"
echo "i.e. $0 (2+2)*3"
echo ''
exit
fi
echo $1 | /usr/bin/bc -l 2>&1 /dev/null
Here is the output
./math "2 + 3 *( 5 - 3 )" <---command
./math: [2: command not found
8
On Wed, 11 Dec 2002, Francisco Neira wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> dbrett wrote:
> | I have a bash to math calucations. It works but also complains about the
> | last line, even though it works.
> |
> | Any ideas how to fix the problem or at least not see the error message and
> | still work.
> |
> | #!/bin/bash
> |
> | if [$1 == '']; then
> | echo ''
> | echo "format is $0 'math equation'"
> | echo "i.e. $0 (2+2)*3"
> | echo ''
> | exit
> | fi
> |
> | echo $1 | /usr/bin/bc -l &2>/dev/null
> |
> | unfortunately '&2>/dev/null has an additional problem.
> |
> | david
> |
> |
> |
> |
> |
>
> And 2>&1 /dev/null works?
>
>
> - --
> Francisco Neira B. /~\ The ASCII
> Administrador de Red \ / Ribbon Campaign
> Defensoria del Pueblo X Against
> Lima, Peru, -05:00 UTC / \ HTML Email
> PGP Pub Key at http://portal.defensoria.gob.pe/~fneira/llavepublica.asc
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAj33gCMACgkQkGxqImhGCe5GGwCfaYB51Dq+wJ78NF7mlvLZBunB
> pp8An19Kngm4UHlej3BbIX4fN3+cLJUB
> =Hu5o
> -----END PGP SIGNATURE-----
>
>
>
> --
> redhat-list mailing list
> unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
> https://listman.redhat.com/mailman/listinfo/redhat-list
>
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list