get a number/amount only from `ledger balance ...`

54 views
Skip to first unread message

Sim Tov

unread,
Feb 6, 2022, 3:43:48 PM2/6/22
to Ledger
Hello,

I would like to use the output of `ledger balance ...` in a bash script. I want to get a number/amount only, without all the strings around it... is there a command line option to get amount only (even without commodity/currency sign)?

Thank you!

Martin Michlmayr

unread,
Feb 6, 2022, 7:29:24 PM2/6/22
to ledge...@googlegroups.com
* Sim Tov <smn...@gmail.com> [2022-02-06 12:43]:
This gets you the amount (with the commodity):

ledger bal assets:cash --balance-format "%(amount)"

I'm not sure if you can get just the number, but you can just run this
command through sed or perl to remove the commodity.

--
Martin Michlmayr
https://www.cyrius.com/

Alan

unread,
Feb 15, 2022, 9:27:00 PM2/15/22
to Ledger
You can say "%(clear_commodity(amount))"
Reply all
Reply to author
Forward
0 new messages