Unused Accounts

40 views
Skip to first unread message

Jasel17212

unread,
Jan 26, 2023, 9:11:02 PM1/26/23
to Ledger
Anyone know of a way to list defined but unused accounts, similar to hledger's --unused option?

Martin Michlmayr

unread,
Jan 26, 2023, 9:15:04 PM1/26/23
to ledge...@googlegroups.com
* Jasel17212 <ja...@thelittonfamily.com> [2023-01-26 18:11]:
> Anyone know of a way to list defined but unused accounts, similar to
> hledger's --unused option?

I don't think so.

Why do you need this?

The only way I can think of is:

1) grep for "^account" and find the accounts you defined

2) do "ledger bal --empty" to find all accounts that have been used

the difference is unused accounts; they will not show up, even with
--empty

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

Martin Michlmayr

unread,
Jan 26, 2023, 9:57:40 PM1/26/23
to ledge...@googlegroups.com
* Martin Michlmayr <t...@cyrius.com> [2023-01-27 10:14]:
> The only way I can think of is:

grep "^account" d | sed -e "s/^account *//" | sort | uniq > 1
ledger -f d bal --empty --flat -F "%a\n" | sort | uniq > 2
comm -3 1 2
rm -f 1 2
Message has been deleted

Jasel17212

unread,
Jan 26, 2023, 10:53:46 PM1/26/23
to Ledger
Since there wasn't a built-in option to do this, I came up with the following:

grep "^account" accounts.txt | cut -c 9- | xargs -I{} bash -c "grep -q \"{}\" *.ldg || echo \"{}\""

Thanks
JL

Reply all
Reply to author
Forward
0 new messages