Compute Numerical Values at the Command Line
Basic Math
Experts use tools such as bc and dc for arithmetic in the shell. The num-utils and datamash packages open up further opportunities for processing numerical values at the command line.
Keyboard fans love working at the command line: The shell carries out your commands without any compromises. Only if you enter incorrect information does it let you know its dissatisfaction, but it even does that in an extremely courteous way.
Whether Bash, Dash, zsh, or ksh, the shell initially processes inputs as character strings, making it perfect for most tasks. When it comes to interpreting the input, the command line sometimes needs a little help since it cannot guess on its own when it needs to evaluate input as numeric. Read on to learn how to tell the shell to do this.
The use cases mostly relate to admin and statistics and often involve evaluating logfiles, say for failed login attempts, network statistics, or memory usage. Although there are specialist utilities that do this, knowing how to handle these tasks without their help is a good thing.
[...]
Buy this article as PDF
(incl. VAT)
