Hacker News new | ask | show | jobs
by antoineMoPa 2474 days ago
In bash

  $ echo "print((-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3)" | sed "s/\^/**/g" | python -
  42
4 comments

You're just using python, using bc is more bashy:

    $ echo '(-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3' | bc
    42
Without shelling out:

  $ echo $(((-80538738812075974)**3 + 80435758145817515**3 + 12602123297335631**3))
  42
In calc:

$ calc

calc 2.12.4.1

> (-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3

        42
>

Literally pasted off the web page and verified in a couple of seconds.

One more proof that you can do everything in bash.