ledger(1)

NAME
ledger - Command-line, double-entry account reporting tool

SYNOPSIS
ledger [command] [options] [arguments]

DESCRIPTION
Ledger is a command-line accounting tool providing the user access to the power of double-entry accounting. It is only a reporting tool, which means it never modifies your data files, nor can it be used to create or remove data.

COMMANDS
Ledger accepts several top-level commands, each of which is used to generate a different report. Most of them accept a report-query argument, in order to determine what to report. To understand what is accepted by report-query, see the section on QUERIES. In its most basic form, simply specifying one or more strings will produce a report for all accounts containing those strings.

If no command at all is given, Ledger enters a REPL, or command loop, allowing several commands to be executed against the same dataset without reparsing.

The following is a summary of all the reporting commands accepted by Ledger:

balance [query]
    Produce a balance report showing subtotals for matching leaf accounts, and aggregate totals for all the parents of those accounts. The most common options with this command are:

    --collapse (-n)
        Only show totals in the top-most accounts.
    --empty (-E)
        Show matching accounts whose total happens to be zero.
    --flat
        Rather than displaying a hierarchical tree, flatten it to show only subtotals for accounts directly matching the query.
    --no-total
        Suppress the final total usually shown at the bottom of the report.

    The synonyms bal and b are also accepted.

csv [query]

emacs [query]
    The synonym lisp is also accepted.

equity [query]

generate

prices [query]

pricesdb [query]

print [query]

register [query]
    The synonyms reg and r are also accepted.

reload
    Used solely by the

xact [date]
    The synonym entry is also accepted. REPL, and causes an immediate reloading of all journal files in the session.

stats [query]

OPTIONS

--abbrev-len INT

--account STR

--account-width INT

--actual (-L)

--add-budget

--amount EXPR (-t)

--amount-data (-j)

--amount-width INT

--anon

--args-only

--average (-A)

--balance-format FMT

--base

--basis (-B)

--begin DATE (-b)

--budget

--by-payee (-P)

--cleared (-C)

--code-as-account

--code-as-payee

--collapse (-n)

--collapse-if-zero

--color

--columns INT

--commodity-as-account
    (Also ---comm-as-account ).

--commodity-as-payee
    (Also ---comm-as-payee ).

--cost
    See --basis.

--csv-format FMT

--current (-c)

--daily

--date-format DATEFMT (-y)

--date-width INT

--debug STR

--depth INT

--deviation (-D)

--display EXPR (-d)

--display-amount EXPR

--display-total EXPR

--dow

--download

--effective

--empty (-E)

--end (-e)

--equity

--exact

--exchange COMM [, COMM, ...] (-X)

--file FILE

--first INT
    See --head.

--flat

--forecast-while EXPR
    (Also --forecast ).

--format FMT (-F)

--gain (-G)

--head INT

--init-file FILE

--input-date-format DATEFMT

--invert

--last INT
    See --tail.

--leeway INT (-Z)

--limit EXPR (-l)

--lot-dates

--lot-prices

--lot-tags

--lots

--lots-actual

--market (-V)

--monthly (-M)

--only EXPR

--output FILE (-o)

--pager STR

--payee-as-account

--payee-width INT

--pending

--percentage (-)

--period PERIOD (-p)

--period-sort

--plot-amount-format FMT

--plot-total-format FMT

--price (-I)

--price-db FILE

--price-exp STR
    See --leeway.

--prices-format FMT

--pricesdb-format FMT

--print-format FMT

--quantity (-O)

--quarterly

--raw
    For use only with the print command, it causes Ledger to print out matching entries exactly as they appeared in the original journal file.

--real (-R)

--register-format FMT

--related (-r)

--related-all

--revalued

--revalued-only

--revalued-total EXPR

--seed INT

--script

--set-account EXPR

--set-payee EXPR

--set-price EXPR

--sort EXPR (-S)

--sort-all

--sort-xacts

--start-of-week STR

--strict

--subtotal (-s)

--tail INT

--total EXPR

--total-data (-J)

--total-width INT

--trace INT

--truncate

--unbudgeted

--uncleared (-U)

--unround

--verbose

--verify

--version

--weekly (-W)

--wide (-w)

--yearly (-Y)

PRECOMMANDS

args

eval

format

parse

period

python

template

QUERIES
The syntax for reporting queries can get somewhat complex. It is a series of query terms with an implicit OR operator between them. The following terms are accepted:

regex
    A bare string is taken as a regular expression matching the full account name. Thus, to report the current balance for all assets and liabilities, you would use:

        ledger bal asset liab

payee regex (@regex)
    Query on the payee, rather than the account.

tag regex (%regex)

note regex (=regex)
    Query on anything found in an item's note.

code regex (#regex)
    Query on the xact's optional code (which can be any string the user wishes).

term and term
    Query terms are joined by an implicit OR operator. You can change this to AND by using that keyword. For example, to show food expenditures occurring at Shakee's Pizza, you could say:

        ledger reg food and @Shakee

term or term
    When you wish to be more explicit, use the OR operator.

show

not term
    Reverse the logical meaning of the following term. This can be used with parentheses to great effect:

        ledger reg food and @Shakee and not dining

(term)
    If you wish to mix OR and AND operators, it is often helpful to surround logical units with parentheses. NOTE: Because of the way some shells interpret parentheses, you should always escape them:

        ledger bal \\( assets or liab \\) and not food

EXPRESSIONS

account

account_base

account_amount

actual

amount

amount_expr

ansify_if(value, color, bool)
    Render the given value as a string, applying the proper ANSI escape codes to display it in the given color if bool is true. It typically checks the value of the option ledger --color, for example:
        ansify_if(amount, blue, options.color)

beg_line

beg_pos

calculated

cleared

code

comment

commodity

cost

count

date

depth

depth_spacer

display_amount

display_total

end_line

end_pos

filename

format_date

get_at

has_meta

has_tag

is_seq

join

market

meta

note

null

options

partial_account

payee

pending

post

print

quantity

quoted

real

rounded

scrub

status

strip

subcount

tag

today

total

total_expr

truncate

uncleared

virtual

xact

SEE ALSO
beancount(1,) hledger(1)

AUTHORS
John Wiegley <johnw@newartisans.com>