;bin:ledgereval

This commit is contained in:
Simon Michael 2026-01-09 12:33:46 -10:00
parent c3ea87ca20
commit a55455e19d
2 changed files with 14 additions and 0 deletions

View File

@ -38,6 +38,12 @@ Here are some scripts which don't use hledger directly, but might be useful to h
(For more, see also: [plaintextaccounting.org > Software](https://plaintextaccounting.org#software)).
### ledgereval
[`ledgereval`](https://github.com/simonmichael/hledger/blob/master/bin/ledgereval
is a helper for evaluating Ledger value expressions.
It's useful eg when converting amount expressions like `(1 USD + 2 USD)` to simple amounts.
### pricehist
[pricehist](https://pypi.org/project/pricehist) is useful for downloading market prices / conversion rates; recommended.

8
bin/ledgereval Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
# ledgereval [EXPR] - evaluate a Ledger value expression
# This runs `ledger eval`, but also accepts standard input, and does not add a newline.
# It's useful eg when converting Ledger's amount expressions to simple amounts.
# Decimal places can be important, eg ledgereval '0.01 USD / 2' vs ledgereval '0.010 USD / 2'.
expr="${*:-$(cat)}"
printf '%s' "$(ledger eval "$expr")"