Skip to content

Instantly share code, notes, and snippets.

@enriched
Created May 2, 2016 19:26
Show Gist options
  • Save enriched/73126f89292c9e15c8a281ba3a3777e9 to your computer and use it in GitHub Desktop.
Save enriched/73126f89292c9e15c8a281ba3a3777e9 to your computer and use it in GitHub Desktop.
Floating point math in bash without bc (using awk)
#!/bin/bash
# Uses awk to do the comparison so it can handle floating point numbers
awke()
{
echo "$1 $3" | awk '{ print ($1 '"$2"' $2) }'
}
awke '3.124' '*' '6'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment