Hacker News new | ask | show | jobs
by city41 3275 days ago
Being able to do arithmetic right in the shell is handy.
2 comments

  $ echo $((1 + 2 * 3 - 4))
  3
With zsh, you can even save a few keystrokes.

  function c() {
    echo $(($@))
  }
  alias c='noglob c'
zsh can handle floating point arithmetic too, while bash can't.
They way they chose to do it though seems to create some ambiguity. Like, what does this do? I can think of 3 distinctly different things it could do.

$ echo test 1 + 2>err

Or what if there are files with these names?

$ cp /bin/grep 42

$ 42 + 1