Hacker News new | ask | show | jobs
by geraldcombs 2209 days ago
I do something similar, with a couple of convenience substitutions for commas and multiplication:

$ math() { echo "scale=2 ; $" | sed -e "s:x::g" | sed -e "s:,::g" | bc; }

$ math 5,382 x 48,927.3

263326728.6

1 comments

You should put this into a codeblock by indenting by 2 spaces. The formatting converts asterisk-delimited text into italics.

  $ math() { echo "scale=2 ; $*" | sed -e "s:x:*:g" | sed -e "s:,::g" | bc; }
  
  $ math 5,382 x 48,927.3
  
  263326728.6