-
-
Save thcipriani/915b47d59308db2bd9ea8a70e6719b1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
printf '%s°C\n' "$(units "tempF($@)" 'tempC' | xargs)" | |
printf '%s°F\n' "$(units "tempC($@)" 'tempF' | xargs)" |
It should be noted that this doesn't work with macOS' built-in units
. It will work with gnu-units
though.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should be portable for anything with ZSH
Bash doesn't do floating point, so another option would be
bc
which generally comes with most linux distros and macos.