https://github.com/albinodrought/bc-currency-conversion
Currency conversion from GNU bc using GNU units
https://github.com/albinodrought/bc-currency-conversion
Last synced: about 2 months ago
JSON representation
Currency conversion from GNU bc using GNU units
- Host: GitHub
- URL: https://github.com/albinodrought/bc-currency-conversion
- Owner: AlbinoDrought
- License: cc0-1.0
- Created: 2021-03-23T01:26:00.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T01:26:48.000Z (about 4 years ago)
- Last Synced: 2025-02-07T02:46:35.294Z (3 months ago)
- Language: Shell
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Currency Conversion for GNU bc
Combine GNU units with GNU bc
## Requirements
- [GNU units](https://www.gnu.org/software/units/)
- [GNU bc](https://www.gnu.org/software/bc/)## Usage
### Generating Script
`gen.sh` creates a bc-compatible script based on the configured currencies. You need to pass the output of it to `bc`.
Oneliner:
```sh
{ ./gen.sh; cat } | bc -li
```Twoliner:
```sh
./gen.sh > conversion.bc
bc -l conversion.bc
```### Converting Currencies
Once the script is loaded, the conversion functions can be used like:
```bc
usd2cad(1)
1.2721644cad2usd(10)
7.86061910usd2eur(10)
8.25120920usd2eur(cad2usd(gbp2cad(10)))
11.24751946386381953707
```### More Currencies
Add them to the `currencies` array in [`gen.sh`](./gen.sh)
### Updating Rates
If your currency conversion rates are out of date, try running `units_cur` as root: https://www.gnu.org/software/units/manual/html_node/Currency.html