LinuxCommandLibrary

ledger

Track financial transactions and generate reports

TLDR

Print a balance report showing totals

$ ledger balance --file [path/to/ledger.journal]
copy

List all postings in Expenses ordered by amount
$ ledger register [expenses] --sorted [amount]
copy

Print total Expenses other than Drinks and Food
$ ledger balance [Expenses] and not ([Drinks] or [Food])
copy

Print a budget report
$ ledger budget
copy

Print summary information about all the postings
$ ledger stats
copy

SYNOPSIS

ledger [options] [command] [arguments]
Common commands include:
   ledger balance [account-regex] [options]
   ledger register [account-regex] [options]
   ledger print [options]
   ledger csv [options]

PARAMETERS

--file FILE, -f FILE
    Specifies the ledger data file to use. This is often the primary way to point ledger to your financial data.

--account REGEX, -a REGEX
    Restricts reports to postings matching the specified account regular expression, allowing focused analysis on particular accounts.

--payee REGEX, -p REGEX
    Filters transactions to include only those whose payee matches the given regular expression.

--begin DATE, -b DATE
    Includes transactions occurring on or after the specified date. Dates can be in various formats (e.g., YYYY/MM/DD).

--end DATE, -e DATE
    Includes transactions occurring on or before the specified date, allowing for end-dated reports.

--period PERIOD
    Groups and aggregates transactions by a specified period, such as 'daily', 'weekly', 'monthly', or 'yearly', useful for periodic reports.

--cleared, -c
    Shows only transactions that have been marked as cleared, typically indicating they've been reconciled with a bank statement.

--pending, -P
    Displays only transactions that are marked as pending, useful for tracking future or unconfirmed movements.

--value
    Converts all amounts in the report to their equivalent value in the default commodity (e.g., USD), using historical prices if available.

--format FORMAT, -F FORMAT
    Applies a custom format string to the output, providing highly customizable reporting capabilities.

--sort EXPR
    Sorts the output entries based on a custom expression, allowing flexible ordering of reports.

--collapse, -l
    For balance reports, this option collapses sub-accounts into their parent accounts, showing a more summarized view.

--flat, -L
    When used with the balance command, it flattens the account hierarchy, listing all accounts at the same level.

--empty
    When used with the balance command, this option forces the display of accounts even if their current balance is zero.

--average, -A
    When used with the register command, displays the average balance for each period, offering insights into trends.

DESCRIPTION

Ledger is a robust, command-line, double-entry accounting system that operates on a plain-text file. Unlike traditional accounting software, it does not use a database or a graphical user interface, making it highly transparent, flexible, and scriptable. Users define transactions in a human-readable text file (typically named .ledger), specifying accounts, amounts, payees, and dates.

Its primary purpose is to help individuals and small businesses manage finances, track income and expenses, reconcile accounts, and generate various financial reports such as balance sheets, income statements, and registers. Ledger supports multiple currencies, budgeting, forecasting, and powerful querying capabilities, allowing users to filter and sort transactions based on complex criteria. Its plain-text nature makes it ideal for version control systems like Git, enabling easy tracking of financial history and collaborative use. It empowers users who prefer a minimalist, text-based workflow for their financial management.

CAVEATS

While powerful, Ledger has a few considerations:
Steep Learning Curve: New users, especially those unfamiliar with double-entry accounting or command-line tools, may find the initial setup and syntax challenging.
No GUI: It operates purely from the command line, which might not suit users who prefer graphical interfaces for financial management.
Manual File Editing: All transactions are entered and edited directly in a plain-text file, requiring careful adherence to the syntax to avoid errors.

<B>THE LEDGER FILE FORMAT</B>

Ledger uses a simple, human-readable plain-text file format. Each transaction typically includes a date, an optional cleared status, a payee/description, and multiple postings (debits and credits) to various accounts. This format's simplicity allows for easy version control (e.g., with Git) and integration with other text-processing tools.

<B>SCRIPTABILITY AND AUTOMATION</B>

Due to its command-line nature and plain-text data files, Ledger is highly scriptable. Users can automate tasks like downloading bank statements (using external tools), importing data, generating periodic reports via cron jobs, and integrating with custom scripts using tools like grep, awk, or Python.

HISTORY

Ledger was created by John Wiegley, with its initial public release occurring around 2003. It was developed in C++ and designed from the ground up to be a fast, robust, and extensible command-line tool for managing personal and small-business finances. Its development aimed to provide a powerful alternative to traditional accounting software by leveraging the simplicity and flexibility of plain-text data files. Over the years, it has maintained an active development community, ensuring its continued relevance and evolution as a core tool for text-based financial management.

SEE ALSO

hledger(1), beancount(1), gnucash(1)

Copied to clipboard