You can print your ledger file in a consistent format. Useful if you want all transactions to be in a consistent format and your file to always be ordered by date.
Run ledger -f ledger.dat print
2021/12/01 Checking balance
Assets:Bank:Checking 1000.00
Equity:Opening Balances -1000.00
2021/12/05 Withdrawl
Assets:Bank:Checking -100.00
Assets:Cash:Wallet 100.00
2021/12/22 Grocery Store
Assets:Bank:Checking -222.00
Expenses:Food:Groceries 222.00
2021/12/25 Buy some Crypto
Assets:Bank:Checking -500.00
Assets:Crypto:BTC 300.00
Assets:Crypto:ETH 200.00
2021/12/31 Employer
Assets:Bank:Checking 2000.00
Income:Salary -2000.00
2022/01/02 Dominoes Pizza HOUSTON TX
Expenses:Food:TakeOut 23.58
Liabilities:MasterCard -23.58
2022/01/02 Grocery Store
Assets:Bank:Checking -145.00
Expenses:Food:Groceries 145.00
2022/01/02 Grocery Store
Assets:Bank:Checking -180.00
Expenses:Food:Groceries 180.00
2022/01/08 Half Price Books HOUSTON TX
Expenses:Books 20.00
Liabilities:MasterCard -20.00
2022/01/09 Grocery Store
Assets:Bank:Checking -120.00
Expenses:Food:Groceries 120.00
2022/01/11 Panda Express
Expenses:Food:TakeOut 17.34
Liabilities:MasterCard -17.34
2022/01/15 Employer
Assets:Bank:Checking 2000.00
Income:Salary -2000.00
You can also use this if your splitting off transactions into separate files by date range, or account.
All 2021 transactions for example ledger -f ledger.dat -b "2021/01/01" -e "2022/01/01" print
2021/12/01 Checking balance
Assets:Bank:Checking 1000.00
Equity:Opening Balances -1000.00
2021/12/05 Withdrawl
Assets:Bank:Checking -100.00
Assets:Cash:Wallet 100.00
2021/12/22 Grocery Store
Assets:Bank:Checking -222.00
Expenses:Food:Groceries 222.00
2021/12/25 Buy some Crypto
Assets:Bank:Checking -500.00
Assets:Crypto:BTC 300.00
Assets:Crypto:ETH 200.00
2021/12/31 Employer
Assets:Bank:Checking 2000.00
Income:Salary -2000.00