Next: , Previous: Report filtering, Up: Options


2.3.3 Output customization

These options affect only the output, but not which transactions are used to create it:

--collapse (-n) causes entries in a register report with multiple transactions to be collapsed into a single, subtotaled entry.

--subtotal (-s) causes all entries in a register report to be collapsed into a single, subtotaled entry.

--by-payee (-P) reports subtotals by payee.

--comm-as-payee (-x) changes the payee of every transaction to be the commodity used in that transaction. This can be useful when combined with other options, such as -s.

--empty (-E) includes even empty accounts in the balance report.

--weekly (-W) reports transaction totals by the week. The week begins on whichever day of the week begins the month containing that transaction. To set a specific begin date, use a period string, such as ‘weekly from DATE’. --monthly (-M) reports transaction totals by month; --yearly (-Y) reports transaction totals by year. For more complex period, using the --period option described above.

--dow reports transactions totals for each day of the week. This is an easy way to see if weekend spending is more than on weekdays.

--sort EXPR (-S EXPR) sorts a report by comparing the values determined using the value expression EXPR. For example, using -S -UT in the balance report will sort account balances from greatest to least, using the absolute value of the total. For more on how to use value expressions, see Value expressions.

--wide (-w) causes the default register report to assume 132 columns instead of 80.

--head causes only the first N entries to be printed. This is different from using the command-line utility head, which would limit to the first N transactions. --tail outputs only the last N entries. Both options may be used simultaneously. If a negative amount is given, it will invert the meaning of the flag (instead of the first five entries being printed, for example, it would print all but the first five).

--pager tells Ledger to pass its output to the given pager program—very useful when the output is especially long. This behavior can be made the default by setting the LEDGER_PAGER environment variable.

--average (-A) reports the average transaction value.

--deviation (-D) reports each transaction's deviation from the average. It is only meaningful in the register and prices reports.

--percentage (-%) shows account subtotals in the balance report as percentages of the parent account.

--totals include running total information in the xml report.

--amount-data (-j) changes the register report so that it output nothing but the date and the value column, and the latter without commodities. This is only meaningful if the report uses a single commodity. This data can then be fed to other programs, which could plot the date, analyze it, etc.

--total-data (-J) changes the register report so that it output nothing but the date and totals column, without commodities.

--display EXPR (-d EXPR) limits which transactions or accounts or actually displayed in a report. They might still be calculated, and be part of the running total of a register report, for example, but they will not be displayed. This is useful for seeing last month's checking transactions, against a running balance which includes all transaction values:

     ledger -d "d>=[last month]" reg checking

The output from this command is very different from the following, whose running total includes only transactions from the last month onward:

     ledger -p "last month" reg checking

Which is more useful depends on what you're looking to know: the total amount for the reporting range (-p), or simply a display restricted to the reporting range (using -d).

--date-format STR (-y STR) changes the basic date format used by reports. The default uses a date like 2004/08/01, which represents the default date format of ‘%Y/%m/%d’. To change the way dates are printed in general, the easiest way is to put --date-format FORMAT in the Ledger initialization file ~/.ledgerrc (or the file referred to by LEDGER_INIT).

--format STR (-F STR) sets the reporting format for whatever report ledger is about to make. See Format strings. There are also specific format commands for each report type: