News for hackers. Stuff that matters.
Re:Bash patterns I use weekly by edgyquant on Tuesday November 23, 2021 @06:26PM (#29324907)
It’s funny I’ve been using Linux for a decade and a half, professionally for about half that time, and yet I still go to python when arithmetic is involved. I’ve been learning a lot about the shell lately it’s like I did the bare minimum with bash just to be able to run programs and slightly automate things and it took this long for it to click with me that it’s a productive programming language in its own right (and probably faster than python.)
Re:Bash patterns I use weekly by yesenadam on Thursday November 25, 2021 @08:21AM (#29341120)
I use "python calc" for quick calculations at the command line:

  pc () { python3 -c "print($*)" ; } 

  $ pc 3.5**2.4
  20.219169193375105
Or "awk calc", which seems much faster: (and ^ and ** both work for powers)

  calc () { awk "BEGIN{print $*}" ; }

  $ calc 3.5**2.4
  20.2192
Re:Bash patterns I use weekly by chasil on Tuesday November 23, 2021 @07:14PM (#29325390)
With the original Borne shell, the exper command was used for arithmetic.

The POSIX shell allows the $(( form for native shell arithmetic, but not the (( alternative found in bash and Korn.