cli: doc: queries: clarifications, especially not:

This commit is contained in:
Simon Michael 2017-09-07 08:35:53 -07:00
parent 75df6e0277
commit 81d7d3f709
4 changed files with 335 additions and 338 deletions

View File

@ -937,12 +937,12 @@ Most commands accept an optional query expression, written as arguments
after the command name, to filter the data by date, account name or
other criteria.
The syntax is similar to a web search: one or more space\-separated
search terms, quotes to enclose whitespace, optional prefixes to match
specific fields.
Multiple search terms are combined as follows:
search terms, quotes to enclose whitespace, prefixes to match specific
fields, a not: prefix to negate the match.
.PP
All commands except print: show transactions/postings/accounts which
match (or negatively match)
We do not yet support arbitrary boolean combinations of search terms;
instead most commands show transactions/postings/accounts which match
(or negatively match):
.IP \[bu] 2
any of the description terms AND
.IP \[bu] 2
@ -952,7 +952,7 @@ any of the status terms AND
.IP \[bu] 2
all the other terms.
.PP
The print command: show transactions which
The print command instead shows transactions which:
.IP \[bu] 2
match any of the description terms AND
.IP \[bu] 2
@ -962,10 +962,13 @@ have no postings matching any of the negative account terms AND
.IP \[bu] 2
match all the other terms.
.PP
The following kinds of search terms can be used:
The following kinds of search terms can be used.
Remember these can also be prefixed with \f[B]\f[C]not:\f[]\f[], eg to
exclude a particular subaccount.
.TP
.B \f[B]\f[C]REGEX\f[]\f[]
match account names by this regular expression
match account names by this regular expression.
(No prefix is equivalent to \f[C]acct:\f[]).
.RS
.RE
.TP
@ -1057,18 +1060,13 @@ Also remember that postings inherit the tags of their parent
transaction.
.RS
.RE
.TP
.B \f[B]\f[C]not:\f[]\f[]
before any of the above negates the match.
.RS
.RE
.PP
The following special search term is used only you click an account name
in hledger\-web:
.TP
.B \f[B]\f[C]inacct:ACCTNAME\f[]\f[]
a special term used automatically when you click an account name in
hledger\-web, specifying the account register we are currently in
(selects the transactions of that account and how to show them, can be
filtered further with \f[C]acct\f[] etc).
Not supported elsewhere in hledger.
tells hledger\-web to show the transaction register for this account.
Can be filtered further with \f[C]acct\f[] etc.
.RS
.RE
.PP

View File

@ -666,29 +666,32 @@ subsets of your data. Most commands accept an optional query
expression, written as arguments after the command name, to filter the
data by date, account name or other criteria. The syntax is similar to
a web search: one or more space-separated search terms, quotes to
enclose whitespace, optional prefixes to match specific fields.
Multiple search terms are combined as follows:
enclose whitespace, prefixes to match specific fields, a not: prefix to
negate the match.
All commands except print: show transactions/postings/accounts which
match (or negatively match)
We do not yet support arbitrary boolean combinations of search terms;
instead most commands show transactions/postings/accounts which match
(or negatively match):
* any of the description terms AND
* any of the account terms AND
* any of the status terms AND
* all the other terms.
The print command: show transactions which
The print command instead shows transactions which:
* match any of the description terms AND
* have any postings matching any of the positive account terms AND
* have no postings matching any of the negative account terms AND
* match all the other terms.
The following kinds of search terms can be used:
The following kinds of search terms can be used. Remember these can
also be prefixed with *'not:'*, eg to exclude a particular subaccount.
*'REGEX'*
match account names by this regular expression
match account names by this regular expression. (No prefix is
equivalent to 'acct:').
*'acct:REGEX'*
same as above
@ -749,16 +752,14 @@ match (or negatively match)
query is considered to match a transaction if it matches any of the
postings. Also remember that postings inherit the tags of their
parent transaction.
*'not:'*
before any of the above negates the match.
The following special search term is used only you click an account
name in hledger-web:
*'inacct:ACCTNAME'*
a special term used automatically when you click an account name in
hledger-web, specifying the account register we are currently in
(selects the transactions of that account and how to show them, can
be filtered further with 'acct' etc). Not supported elsewhere in
hledger.
tells hledger-web to show the transaction register for this
account. Can be filtered further with 'acct' etc.
Some of these can also be expressed as command-line options (eg
'depth:2' is equivalent to '--depth 2'). Generally you can mix options
@ -2162,95 +2163,95 @@ Node: Regular expressions19999
Ref: #regular-expressions20137
Node: QUERIES21498
Ref: #queries21602
Node: COMMANDS25534
Ref: #commands25648
Node: accounts26327
Ref: #accounts26427
Node: activity27409
Ref: #activity27521
Node: add27880
Ref: #add27981
Node: balance30639
Ref: #balance30752
Node: Flat mode33767
Ref: #flat-mode33894
Node: Depth limited balance reports34314
Ref: #depth-limited-balance-reports34517
Node: Multicolumn balance reports34937
Ref: #multicolumn-balance-reports35148
Node: Custom balance output39796
Ref: #custom-balance-output39980
Node: Colour support42073
Ref: #colour-support42234
Node: Output destination42407
Ref: #output-destination42565
Node: CSV output42835
Ref: #csv-output42954
Node: balancesheet43351
Ref: #balancesheet43489
Node: balancesheetequity45396
Ref: #balancesheetequity45547
Node: cashflow46336
Ref: #cashflow46459
Node: help48310
Ref: #help48422
Node: incomestatement49496
Ref: #incomestatement49627
Node: print51519
Ref: #print51636
Node: register55392
Ref: #register55505
Node: Custom register output60001
Ref: #custom-register-output60132
Node: stats61429
Ref: #stats61535
Node: test62416
Ref: #test62503
Node: ADD-ON COMMANDS62871
Ref: #add-on-commands62983
Node: Official add-ons64270
Ref: #official-add-ons64412
Node: api64499
Ref: #api64590
Node: ui64642
Ref: #ui64743
Node: web64801
Ref: #web64892
Node: Third party add-ons64938
Ref: #third-party-add-ons65115
Node: diff65250
Ref: #diff65349
Node: iadd65448
Ref: #iadd65564
Node: interest65647
Ref: #interest65770
Node: irr65865
Ref: #irr65965
Node: Experimental add-ons66043
Ref: #experimental-add-ons66197
Node: autosync66599
Ref: #autosync66713
Node: budget66952
Ref: #budget67076
Node: chart67142
Ref: #chart67261
Node: check67332
Ref: #check67456
Node: check-dates67523
Ref: #check-dates67665
Node: check-dupes67738
Ref: #check-dupes67881
Node: equity67958
Ref: #equity68086
Node: prices68205
Ref: #prices68334
Node: print-unique68389
Ref: #print-unique68538
Node: register-match68631
Ref: #register-match68787
Node: rewrite68885
Ref: #rewrite69019
Node: tags69097
Ref: #tags69202
Node: COMMANDS25580
Ref: #commands25694
Node: accounts26373
Ref: #accounts26473
Node: activity27455
Ref: #activity27567
Node: add27926
Ref: #add28027
Node: balance30685
Ref: #balance30798
Node: Flat mode33813
Ref: #flat-mode33940
Node: Depth limited balance reports34360
Ref: #depth-limited-balance-reports34563
Node: Multicolumn balance reports34983
Ref: #multicolumn-balance-reports35194
Node: Custom balance output39842
Ref: #custom-balance-output40026
Node: Colour support42119
Ref: #colour-support42280
Node: Output destination42453
Ref: #output-destination42611
Node: CSV output42881
Ref: #csv-output43000
Node: balancesheet43397
Ref: #balancesheet43535
Node: balancesheetequity45442
Ref: #balancesheetequity45593
Node: cashflow46382
Ref: #cashflow46505
Node: help48356
Ref: #help48468
Node: incomestatement49542
Ref: #incomestatement49673
Node: print51565
Ref: #print51682
Node: register55438
Ref: #register55551
Node: Custom register output60047
Ref: #custom-register-output60178
Node: stats61475
Ref: #stats61581
Node: test62462
Ref: #test62549
Node: ADD-ON COMMANDS62917
Ref: #add-on-commands63029
Node: Official add-ons64316
Ref: #official-add-ons64458
Node: api64545
Ref: #api64636
Node: ui64688
Ref: #ui64789
Node: web64847
Ref: #web64938
Node: Third party add-ons64984
Ref: #third-party-add-ons65161
Node: diff65296
Ref: #diff65395
Node: iadd65494
Ref: #iadd65610
Node: interest65693
Ref: #interest65816
Node: irr65911
Ref: #irr66011
Node: Experimental add-ons66089
Ref: #experimental-add-ons66243
Node: autosync66645
Ref: #autosync66759
Node: budget66998
Ref: #budget67122
Node: chart67188
Ref: #chart67307
Node: check67378
Ref: #check67502
Node: check-dates67569
Ref: #check-dates67711
Node: check-dupes67784
Ref: #check-dupes67927
Node: equity68004
Ref: #equity68132
Node: prices68251
Ref: #prices68380
Node: print-unique68435
Ref: #print-unique68584
Node: register-match68677
Ref: #register-match68833
Node: rewrite68931
Ref: #rewrite69065
Node: tags69143
Ref: #tags69248

End Tag Table

View File

@ -605,11 +605,12 @@ QUERIES
sion, written as arguments after the command name, to filter the data
by date, account name or other criteria. The syntax is similar to a
web search: one or more space-separated search terms, quotes to enclose
whitespace, optional prefixes to match specific fields. Multiple
search terms are combined as follows:
whitespace, prefixes to match specific fields, a not: prefix to negate
the match.
All commands except print: show transactions/postings/accounts which
match (or negatively match)
We do not yet support arbitrary boolean combinations of search terms;
instead most commands show transactions/postings/accounts which match
(or negatively match):
o any of the description terms AND
@ -619,7 +620,7 @@ QUERIES
o all the other terms.
The print command: show transactions which
The print command instead shows transactions which:
o match any of the description terms AND
@ -629,30 +630,32 @@ QUERIES
o match all the other terms.
The following kinds of search terms can be used:
The following kinds of search terms can be used. Remember these can
also be prefixed with not:, eg to exclude a particular subaccount.
REGEX match account names by this regular expression
REGEX match account names by this regular expression. (No prefix is
equivalent to acct:).
acct:REGEX
same as above
amt:N, amt:<N, amt:<=N, amt:>N, amt:>=N
match postings with a single-commodity amount that is equal to,
less than, or greater than N. (Multi-commodity amounts are not
match postings with a single-commodity amount that is equal to,
less than, or greater than N. (Multi-commodity amounts are not
tested, and will always match.) The comparison has two modes: if
N is preceded by a + or - sign (or is 0), the two signed numbers
are compared. Otherwise, the absolute magnitudes are compared,
are compared. Otherwise, the absolute magnitudes are compared,
ignoring sign.
code:REGEX
match by transaction code (eg check number)
cur:REGEX
match postings or transactions including any amounts whose cur-
rency/commodity symbol is fully matched by REGEX. (For a par-
match postings or transactions including any amounts whose cur-
rency/commodity symbol is fully matched by REGEX. (For a par-
tial match, use .*REGEX.*). Note, to match characters which are
regex-significant, like the dollar sign ($), you need to prepend
\. And when using the command line you need to add one more
\. And when using the command line you need to add one more
level of quoting to hide it from the shell, so eg do:
hledger print cur:'\$' or hledger print cur:\\$.
@ -661,20 +664,20 @@ QUERIES
date:PERIODEXPR
match dates within the specified period. PERIODEXPR is a period
expression (with no report interval). Examples: date:2016,
date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the
--date2 command line flag is present, this matches secondary
expression (with no report interval). Examples: date:2016,
date:thismonth, date:2000/2/1-2/15, date:lastweek-. If the
--date2 command line flag is present, this matches secondary
dates instead.
date2:PERIODEXPR
match secondary dates within the specified period.
depth:N
match (or display, depending on command) accounts at or above
match (or display, depending on command) accounts at or above
this depth
note:REGEX
match transaction notes (part of description right of |, or
match transaction notes (part of description right of |, or
whole description when there's no |)
payee:REGEX
@ -688,34 +691,32 @@ QUERIES
match unmarked, pending, or cleared transactions respectively
tag:REGEX[=REGEX]
match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches
any of the postings. Also remember that postings inherit the
match by tag name, and optionally also by tag value. Note a
tag: query is considered to match a transaction if it matches
any of the postings. Also remember that postings inherit the
tags of their parent transaction.
not: before any of the above negates the match.
The following special search term is used only you click an account
name in hledger-web:
inacct:ACCTNAME
a special term used automatically when you click an account name
in hledger-web, specifying the account register we are currently
in (selects the transactions of that account and how to show
them, can be filtered further with acct etc). Not supported
elsewhere in hledger.
tells hledger-web to show the transaction register for this
account. Can be filtered further with acct etc.
Some of these can also be expressed as command-line options (eg depth:2
is equivalent to --depth 2). Generally you can mix options and query
arguments, and the resulting query will be their intersection (perhaps
is equivalent to --depth 2). Generally you can mix options and query
arguments, and the resulting query will be their intersection (perhaps
excluding the -p/--period option).
COMMANDS
hledger provides a number of subcommands; hledger with no arguments
hledger provides a number of subcommands; hledger with no arguments
shows a list.
If you install additional hledger-* packages, or if you put programs or
scripts named hledger-NAME in your PATH, these will also be listed as
scripts named hledger-NAME in your PATH, these will also be listed as
subcommands.
Run a subcommand by writing its name as first argument (eg
Run a subcommand by writing its name as first argument (eg
hledger incomestatement). You can also write any unambiguous prefix of
a command name (hledger inc), or one of the standard short aliases dis-
played in the command list (hledger is).
@ -730,14 +731,14 @@ COMMANDS
--drop=N
in flat mode: omit N leading account name parts
This command lists all account names that are in use (ie, all the
accounts which have at least one transaction posting to them). With
This command lists all account names that are in use (ie, all the
accounts which have at least one transaction posting to them). With
query arguments, only matched account names are shown.
It shows a flat list by default. With --tree, it uses indentation to
It shows a flat list by default. With --tree, it uses indentation to
show the account hierarchy.
In flat mode you can add --drop N to omit the first few account name
In flat mode you can add --drop N to omit the first few account name
components.
Examples:
@ -780,8 +781,8 @@ COMMANDS
activity
Show an ascii barchart of posting counts per interval.
The activity command displays an ascii histogram showing transaction
counts by day, week, month or other reporting interval (by day is the
The activity command displays an ascii histogram showing transaction
counts by day, week, month or other reporting interval (by day is the
default). With query arguments, it counts only matched transactions.
$ hledger activity --quarterly
@ -794,24 +795,24 @@ COMMANDS
Prompt for transactions and add them to the journal.
--no-new-accounts
don't allow creating new accounts; helps prevent typos when
don't allow creating new accounts; helps prevent typos when
entering account names
Many hledger users edit their journals directly with a text editor, or
generate them from CSV. For more interactive data entry, there is the
add command, which prompts interactively on the console for new trans-
actions, and appends them to the journal file (if there are multiple
Many hledger users edit their journals directly with a text editor, or
generate them from CSV. For more interactive data entry, there is the
add command, which prompts interactively on the console for new trans-
actions, and appends them to the journal file (if there are multiple
-f FILE options, the first file is used.) Existing transactions are not
changed. This is the only hledger command that writes to the journal
changed. This is the only hledger command that writes to the journal
file.
To use it, just run hledger add and follow the prompts. You can add as
many transactions as you like; when you are finished, enter . or press
many transactions as you like; when you are finished, enter . or press
control-d or control-c to exit.
Features:
o add tries to provide useful defaults, using the most similar recent
o add tries to provide useful defaults, using the most similar recent
transaction (by description) as a template.
o You can also set the initial defaults with command line arguments.
@ -819,20 +820,20 @@ COMMANDS
o Readline-style edit keys can be used during data entry.
o The tab key will auto-complete whenever possible - accounts, descrip-
tions, dates (yesterday, today, tomorrow). If the input area is
tions, dates (yesterday, today, tomorrow). If the input area is
empty, it will insert the default value.
o If the journal defines a default commodity, it will be added to any
o If the journal defines a default commodity, it will be added to any
bare numbers entered.
o A parenthesised transaction code may be entered following a date.
o Comments and tags may be entered following a description or amount.
o If you make a mistake, enter < at any prompt to restart the transac-
o If you make a mistake, enter < at any prompt to restart the transac-
tion.
o Input prompts are displayed in a different colour when the terminal
o Input prompts are displayed in a different colour when the terminal
supports it.
Example (see the tutorial for a detailed explanation):
@ -869,7 +870,7 @@ COMMANDS
show balance change in each period (default)
--cumulative
show balance change accumulated across periods (in multicolumn
show balance change accumulated across periods (in multicolumn
reports)
-H --historical
@ -904,13 +905,13 @@ COMMANDS
select the output format. Supported formats: txt, csv.
-o FILE --output-file=FILE
write output to FILE. A file extension matching one of the
write output to FILE. A file extension matching one of the
above formats selects that format.
--pretty-tables
Use unicode to display prettier tables.
The balance command displays accounts and balances. It is hledger's
The balance command displays accounts and balances. It is hledger's
most featureful and versatile command.
$ hledger balance
@ -927,25 +928,25 @@ COMMANDS
--------------------
0
More precisely, the balance command shows the change to each account's
More precisely, the balance command shows the change to each account's
balance caused by all (matched) postings. In the common case where you
do not filter by date and your journal sets the correct opening bal-
do not filter by date and your journal sets the correct opening bal-
ances, this is the same as the account's ending balance.
By default, accounts are displayed hierarchically, with subaccounts
By default, accounts are displayed hierarchically, with subaccounts
indented below their parent. "Boring" accounts, which contain a single
interesting subaccount and no balance of their own, are elided into the
following line for more compact output. (Use --no-elide to prevent
this. Eliding of boring accounts is not yet supported in multicolumn
following line for more compact output. (Use --no-elide to prevent
this. Eliding of boring accounts is not yet supported in multicolumn
reports.)
Each account's balance is the "inclusive" balance - it includes the
Each account's balance is the "inclusive" balance - it includes the
balances of any subaccounts.
Accounts which have zero balance (and no non-zero subaccounts) are
Accounts which have zero balance (and no non-zero subaccounts) are
omitted. Use -E/--empty to show them.
A final total is displayed by default; use -N/--no-total to suppress
A final total is displayed by default; use -N/--no-total to suppress
it:
$ hledger balance -p 2008/6 expenses --no-total
@ -955,9 +956,9 @@ COMMANDS
Flat mode
To see a flat list of full account names instead of the default hierar-
chical display, use --flat. In this mode, accounts (unless
chical display, use --flat. In this mode, accounts (unless
depth-clipped) show their "exclusive" balance, excluding any subaccount
balances. In this mode, you can also use --drop N to omit the first
balances. In this mode, you can also use --drop N to omit the first
few account name components.
$ hledger balance -p 2008/6 expenses -N --flat --drop 1
@ -965,9 +966,9 @@ COMMANDS
$1 supplies
Depth limited balance reports
With --depth N, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less
detail. In flat mode, balances from accounts below the depth limit
With --depth N, balance shows accounts only to the specified depth.
This is very useful to show a complex charts of accounts in less
detail. In flat mode, balances from accounts below the depth limit
will be shown as part of a parent account at the depth limit.
$ hledger balance -N --depth 1
@ -977,12 +978,12 @@ COMMANDS
$1 liabilities
Multicolumn balance reports
With a reporting interval, multiple balance columns will be shown, one
for each report period. There are three types of multi-column balance
With a reporting interval, multiple balance columns will be shown, one
for each report period. There are three types of multi-column balance
report, showing different information:
1. By default: each column shows the sum of postings in that period, ie
the account's change of balance in that period. This is useful eg
the account's change of balance in that period. This is useful eg
for a monthly income statement:
$ hledger balance --quarterly income expenses -E
@ -997,8 +998,8 @@ COMMANDS
-------------------++---------------------------------
|| $-1 $1 0 0
2. With --cumulative: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at
2. With --cumulative: each column shows the ending balance for that
period, accumulating the changes across periods, starting from 0 at
the report start date:
$ hledger balance --quarterly income expenses -E --cumulative
@ -1014,8 +1015,8 @@ COMMANDS
|| $-1 0 0 0
3. With --historical/-H: each column shows the actual historical ending
balance for that period, accumulating the changes across periods,
starting from the actual balance at the report start date. This is
balance for that period, accumulating the changes across periods,
starting from the actual balance at the report start date. This is
useful eg for a multi-period balance sheet, and when you are showing
only the data after a certain start date:
@ -1031,26 +1032,26 @@ COMMANDS
----------------------++-------------------------------------
|| 0 0 0
Multi-column balance reports display accounts in flat mode by default;
Multi-column balance reports display accounts in flat mode by default;
to see the hierarchy, use --tree.
With a reporting interval (like --quarterly above), the report
start/end dates will be adjusted if necessary so that they encompass
With a reporting interval (like --quarterly above), the report
start/end dates will be adjusted if necessary so that they encompass
the displayed report periods. This is so that the first and last peri-
ods will be "full" and comparable to the others.
The -E/--empty flag does two things in multicolumn balance reports:
first, the report will show all columns within the specified report
period (without -E, leading and trailing columns with all zeroes are
not shown). Second, all accounts which existed at the report start
date will be considered, not just the ones with activity during the
The -E/--empty flag does two things in multicolumn balance reports:
first, the report will show all columns within the specified report
period (without -E, leading and trailing columns with all zeroes are
not shown). Second, all accounts which existed at the report start
date will be considered, not just the ones with activity during the
report period (use -E to include low-activity accounts which would oth-
erwise would be omitted).
The -T/--row-total flag adds an additional column showing the total for
each row.
The -A/--average flag adds a column showing the average value in each
The -A/--average flag adds a column showing the average value in each
row.
Here's an example of all three:
@ -1072,7 +1073,7 @@ COMMANDS
# Average is rounded to the dollar here since all journal amounts are
Custom balance output
In simple (non-multi-column) balance reports, you can customise the
In simple (non-multi-column) balance reports, you can customise the
output with --format FMT:
$ hledger balance --format "%20(account) %12(total)"
@ -1090,7 +1091,7 @@ COMMANDS
0
The FMT format string (plus a newline) specifies the formatting applied
to each account/balance pair. It may contain any suitable text, with
to each account/balance pair. It may contain any suitable text, with
data fields interpolated like so:
%[MIN][.MAX](FIELDNAME)
@ -1101,14 +1102,14 @@ COMMANDS
o FIELDNAME must be enclosed in parentheses, and can be one of:
o depth_spacer - a number of spaces equal to the account's depth, or
o depth_spacer - a number of spaces equal to the account's depth, or
if MIN is specified, MIN * depth spaces.
o account - the account's name
o total - the account's balance/posted total, right justified
Also, FMT can begin with an optional prefix to control how multi-com-
Also, FMT can begin with an optional prefix to control how multi-com-
modity amounts are rendered:
o %_ - render on multiple lines, bottom-aligned (the default)
@ -1117,7 +1118,7 @@ COMMANDS
o %, - render on one line, comma-separated
There are some quirks. Eg in one-line mode, %(depth_spacer) has no
There are some quirks. Eg in one-line mode, %(depth_spacer) has no
effect, instead %(account) has indentation built in.
Experimentation may be needed to get pleasing results.
@ -1125,14 +1126,14 @@ COMMANDS
o %(total) - the account's total
o %-20.20(account) - the account's name, left justified, padded to 20
o %-20.20(account) - the account's name, left justified, padded to 20
characters and clipped at 20 characters
o %,%-50(account) %25(total) - account name padded to 50 characters,
total padded to 20 characters, with multiple commodities rendered on
o %,%-50(account) %25(total) - account name padded to 50 characters,
total padded to 20 characters, with multiple commodities rendered on
one line
o %20(total) %2(depth_spacer)%-(account) - the default format for the
o %20(total) %2(depth_spacer)%-(account) - the default format for the
single-column balance report
Colour support
@ -1143,8 +1144,8 @@ COMMANDS
o the output is not being redirected or piped anywhere
Output destination
The balance, print, register and stats commands can write their output
to a destination other than the console. This is controlled by the
The balance, print, register and stats commands can write their output
to a destination other than the console. This is controlled by the
-o/--output-file option.
$ hledger balance -o - # write to stdout (the default)
@ -1152,8 +1153,8 @@ COMMANDS
CSV output
The balance, print and register commands can write their output as CSV.
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet. This is controlled by the -O/--output-format
This is useful for exporting data to other applications, eg to make
charts in a spreadsheet. This is controlled by the -O/--output-format
option, or by specifying a .csv file extension with -o/--output-file.
$ hledger balance -O csv # write CSV to stdout
@ -1167,7 +1168,7 @@ COMMANDS
balances
--cumulative
show balance change accumulated across periods (in multicolumn
show balance change accumulated across periods (in multicolumn
reports), instead of historical ending balances
-H --historical
@ -1198,8 +1199,8 @@ COMMANDS
--format=LINEFORMAT
in single-column balance reports: use this custom line format
This command displays a simple balance sheet. It currently assumes
that you have top-level accounts named asset and liability (plural
This command displays a simple balance sheet. It currently assumes
that you have top-level accounts named asset and liability (plural
forms also allowed.)
$ hledger balancesheet
@ -1222,19 +1223,19 @@ COMMANDS
0
With a reporting interval, multiple columns will be shown, one for each
report period. As with multicolumn balance reports, you can alter the
report mode with --change/--cumulative/--historical. Normally bal-
ancesheet shows historical ending balances, which is what you need for
report period. As with multicolumn balance reports, you can alter the
report mode with --change/--cumulative/--historical. Normally bal-
ancesheet shows historical ending balances, which is what you need for
a balance sheet; note this means it ignores report begin dates.
balancesheetequity
Show a balance sheet including equity. Alias: bse.
Other than showing the equity accounts, this command is exactly the
Other than showing the equity accounts, this command is exactly the
same as the command balancesheet. Please refer to it for the available
options.
This command displays a balancesheet. It currently assumes that you
This command displays a balancesheet. It currently assumes that you
have top-level accounts named asset, liability and equity (plural forms
also allowed.)
@ -1269,7 +1270,7 @@ COMMANDS
show balance change in each period (default)
--cumulative
show balance change accumulated across periods (in multicolumn
show balance change accumulated across periods (in multicolumn
reports), instead of changes during periods
-H --historical
@ -1300,9 +1301,9 @@ COMMANDS
--format=LINEFORMAT
in single-column balance reports: use this custom line format
This command displays a simple cashflow statement It shows the change
in all "cash" (ie, liquid assets) accounts for the period. It cur-
rently assumes that cash accounts are under a top-level account named
This command displays a simple cashflow statement It shows the change
in all "cash" (ie, liquid assets) accounts for the period. It cur-
rently assumes that cash accounts are under a top-level account named
asset and do not contain receivable, :A/R or :fixed.
$ hledger cashflow
@ -1320,20 +1321,20 @@ COMMANDS
$-1
With a reporting interval, multiple columns will be shown, one for each
report period. Normally cashflow shows changes in assets per period,
though as with multicolumn balance reports you can alter the report
report period. Normally cashflow shows changes in assets per period,
though as with multicolumn balance reports you can alter the report
mode with --change/--cumulative/--historical.
help
Show any of the hledger manuals.
The help command displays any of the main hledger manuals, in one of
several ways. Run it with no argument to list the manuals, or provide
The help command displays any of the main hledger manuals, in one of
several ways. Run it with no argument to list the manuals, or provide
a full or partial manual name to select one.
hledger manuals are available in several formats. hledger help will
use the first of these display methods that it finds: info, man,
$PAGER, less, stdout (or when non-interactive, just stdout). You can
hledger manuals are available in several formats. hledger help will
use the first of these display methods that it finds: info, man,
$PAGER, less, stdout (or when non-interactive, just stdout). You can
force a particular viewer with the --info, --man, --pager, --cat flags.
$ hledger help
@ -1363,7 +1364,7 @@ COMMANDS
show balance change in each period (default)
--cumulative
show balance change accumulated across periods (in multicolumn
show balance change accumulated across periods (in multicolumn
reports), instead of changes during periods
-H --historical
@ -1394,8 +1395,8 @@ COMMANDS
--format=LINEFORMAT
in single-column balance reports: use this custom line format
This command displays a simple income statement. It currently assumes
that you have top-level accounts named income (or revenue) and expense
This command displays a simple income statement. It currently assumes
that you have top-level accounts named income (or revenue) and expense
(plural forms also allowed.)
$ hledger incomestatement
@ -1420,8 +1421,8 @@ COMMANDS
0
With a reporting interval, multiple columns will be shown, one for each
report period. Normally incomestatement shows revenues/expenses per
period, though as with multicolumn balance reports you can alter the
report period. Normally incomestatement shows revenues/expenses per
period, though as with multicolumn balance reports you can alter the
report mode with --change/--cumulative/--historical.
print
@ -1431,14 +1432,14 @@ COMMANDS
show all amounts explicitly
-m STR --match=STR
show the transaction whose description is most similar to STR,
show the transaction whose description is most similar to STR,
and is most recent
-O FMT --output-format=FMT
select the output format. Supported formats: txt, csv.
-o FILE --output-file=FILE
write output to FILE. A file extension matching one of the
write output to FILE. A file extension matching one of the
above formats selects that format.
$ hledger print
@ -1466,23 +1467,23 @@ COMMANDS
The print command displays full journal entries (transactions) from the
journal file, tidily formatted.
As of hledger 1.2, print's output is always a valid hledger journal.
However it may not preserve all original content, eg it does not print
As of hledger 1.2, print's output is always a valid hledger journal.
However it may not preserve all original content, eg it does not print
directives or inter-transaction comments.
Normally, transactions' implicit/explicit amount style is preserved:
when an amount is omitted in the journal, it will be omitted in the
output. You can use the -x/--explicit flag to make all amounts
explicit, which can be useful for troubleshooting or for making your
journal more readable and robust against data entry errors. Note, in
this mode postings with a multi-commodity amount (possible with an
implicit amount in a multi-commodity transaction) will be split into
Normally, transactions' implicit/explicit amount style is preserved:
when an amount is omitted in the journal, it will be omitted in the
output. You can use the -x/--explicit flag to make all amounts
explicit, which can be useful for troubleshooting or for making your
journal more readable and robust against data entry errors. Note, in
this mode postings with a multi-commodity amount (possible with an
implicit amount in a multi-commodity transaction) will be split into
multiple single-commodity postings, for valid journal output.
With -B/--cost, amounts with transaction prices are converted to cost
With -B/--cost, amounts with transaction prices are converted to cost
(using the transaction price).
The print command also supports output destination and CSV output.
The print command also supports output destination and CSV output.
Here's an example of print's CSV output:
$ hledger print -Ocsv
@ -1499,20 +1500,20 @@ COMMANDS
"5","2008/12/31","","*","","pay off","","liabilities:debts","1","$","","1","",""
"5","2008/12/31","","*","","pay off","","assets:bank:checking","-1","$","1","","",""
o There is one CSV record per posting, with the parent transaction's
o There is one CSV record per posting, with the parent transaction's
fields repeated.
o The "txnidx" (transaction index) field shows which postings belong to
the same transaction. (This number might change if transactions are
reordered within the file, files are parsed/included in a different
the same transaction. (This number might change if transactions are
reordered within the file, files are parsed/included in a different
order, etc.)
o The amount is separated into "commodity" (the symbol) and "amount"
o The amount is separated into "commodity" (the symbol) and "amount"
(numeric quantity) fields.
o The numeric amount is repeated in either the "credit" or "debit" col-
umn, for convenience. (Those names are not accurate in the account-
ing sense; it just puts negative amounts under credit and zero or
umn, for convenience. (Those names are not accurate in the account-
ing sense; it just puts negative amounts under credit and zero or
greater amounts under debit.)
register
@ -1522,7 +1523,7 @@ COMMANDS
show running total from report start date (default)
-H --historical
show historical running total/balance (includes postings before
show historical running total/balance (includes postings before
report start date)
-A --average
@ -1533,18 +1534,18 @@ COMMANDS
show postings' siblings instead
-w N --width=N
set output width (default: terminal width or COLUMNS. -wN,M
set output width (default: terminal width or COLUMNS. -wN,M
sets description width as well)
-O FMT --output-format=FMT
select the output format. Supported formats: txt, csv.
-o FILE --output-file=FILE
write output to FILE. A file extension matching one of the
write output to FILE. A file extension matching one of the
above formats selects that format.
The register command displays postings, one per line, and their running
total. This is typically used with a query selecting a particular
total. This is typically used with a query selecting a particular
account, to see that account's activity:
$ hledger register checking
@ -1553,8 +1554,8 @@ COMMANDS
2008/06/02 save assets:bank:checking $-1 $1
2008/12/31 pay off assets:bank:checking $-1 0
The --historical/-H flag adds the balance from any undisplayed prior
postings to the running total. This is useful when you want to see
The --historical/-H flag adds the balance from any undisplayed prior
postings to the running total. This is useful when you want to see
only recent activity, with a historically accurate running balance:
$ hledger register checking -b 2008/6 --historical
@ -1564,23 +1565,23 @@ COMMANDS
The --depth option limits the amount of sub-account detail displayed.
The --average/-A flag shows the running average posting amount instead
The --average/-A flag shows the running average posting amount instead
of the running total (so, the final number displayed is the average for
the whole report period). This flag implies --empty (see below). It
is affected by --historical. It works best when showing just one
the whole report period). This flag implies --empty (see below). It
is affected by --historical. It works best when showing just one
account and one commodity.
The --related/-r flag shows the other postings in the transactions of
The --related/-r flag shows the other postings in the transactions of
the postings which would normally be shown.
With a reporting interval, register shows summary postings, one per
With a reporting interval, register shows summary postings, one per
interval, aggregating the postings to each account:
$ hledger register --monthly income
2008/01 income:salary $-1 $-1
2008/06 income:gifts $-1 $-2
Periods with no activity, and summary postings with a zero amount, are
Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the --empty/-E flag to see them:
$ hledger register --monthly income -E
@ -1597,7 +1598,7 @@ COMMANDS
2008/11 0 $-2
2008/12 0 $-2
Often, you'll want to see just one line per interval. The --depth
Often, you'll want to see just one line per interval. The --depth
option helps with this, causing subaccounts to be aggregated:
$ hledger register --monthly assets --depth 1h
@ -1605,19 +1606,19 @@ COMMANDS
2008/06 assets $-1 0
2008/12 assets $-1 $-1
Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of
intervals. This ensures that the first and last intervals are full
Note when using report intervals, if you specify start/end dates these
will be adjusted outward if necessary to contain a whole number of
intervals. This ensures that the first and last intervals are full
length and comparable to the others in the report.
Custom register output
register uses the full terminal width by default, except on windows.
You can override this by setting the COLUMNS environment variable (not
register uses the full terminal width by default, except on windows.
You can override this by setting the COLUMNS environment variable (not
a bash shell variable) or by using the --width/-w option.
The description and account columns normally share the space equally
(about half of (width - 40) each). You can adjust this by adding a
description width as part of --width's argument, comma-separated:
The description and account columns normally share the space equally
(about half of (width - 40) each). You can adjust this by adding a
description width as part of --width's argument, comma-separated:
--width W,D . Here's a diagram:
<--------------------------------- width (W) ---------------------------------->
@ -1633,14 +1634,14 @@ COMMANDS
$ hledger reg -w 100,40 # set overall width 100, description width 40
$ hledger reg -w $COLUMNS,40 # use terminal width, and set description width
The register command also supports the -o/--output-file and -O/--out-
The register command also supports the -o/--output-file and -O/--out-
put-format options for controlling output destination and CSV output.
stats
Show some journal statistics.
-o FILE --output-file=FILE
write output to FILE. A file extension matching one of the
write output to FILE. A file extension matching one of the
above formats selects that format.
$ hledger stats
@ -1655,8 +1656,8 @@ COMMANDS
Accounts : 8 (depth 3)
Commodities : 1 ($)
The stats command displays summary information for the whole journal,
or a matched part of it. With a reporting interval, it shows a report
The stats command displays summary information for the whole journal,
or a matched part of it. With a reporting interval, it shows a report
for each report period.
The stats command also supports -o/--output-file for controlling output
@ -1668,34 +1669,34 @@ COMMANDS
$ hledger test
Cases: 74 Tried: 74 Errors: 0 Failures: 0
This command runs hledger's built-in unit tests and displays a quick
This command runs hledger's built-in unit tests and displays a quick
report. With a regular expression argument, it selects only tests with
matching names. It's mainly used in development, but it's also nice to
be able to check your hledger executable for smoke at any time.
ADD-ON COMMANDS
hledger also searches for external add-on commands, and will include
hledger also searches for external add-on commands, and will include
these in the commands list. These are programs or scripts in your PATH
whose name starts with hledger- and ends with a recognised file exten-
whose name starts with hledger- and ends with a recognised file exten-
sion (currently: no extension, bat,com,exe, hs,lhs,pl,py,rb,rkt,sh).
Add-ons can be invoked like any hledger command, but there are a few
Add-ons can be invoked like any hledger command, but there are a few
things to be aware of. Eg if the hledger-web add-on is installed,
o hledger -h web shows hledger's help, while hledger web -h shows
hledger-web's help.
o Flags specific to the add-on must have a preceding -- to hide them
from hledger. So hledger web --serve --port 9000 will be rejected;
o Flags specific to the add-on must have a preceding -- to hide them
from hledger. So hledger web --serve --port 9000 will be rejected;
you must use hledger web -- --serve --port 9000.
o You can always run add-ons directly if preferred:
o You can always run add-ons directly if preferred:
hledger-web --serve --port 9000.
Add-ons are a relatively easy way to add local features or experiment
with new ideas. They can be written in any language, but haskell
scripts have a big advantage: they can use the same hledger (and
haskell) library functions that built-in commands do, for command-line
Add-ons are a relatively easy way to add local features or experiment
with new ideas. They can be written in any language, but haskell
scripts have a big advantage: they can use the same hledger (and
haskell) library functions that built-in commands do, for command-line
options, journal parsing, reporting, etc.
Here are some hledger add-ons available:
@ -1713,7 +1714,7 @@ ADD-ON COMMANDS
hledger-web provides a simple web interface.
Third party add-ons
These are maintained separately, and usually updated shortly after a
These are maintained separately, and usually updated shortly after a
hledger release.
diff
@ -1721,7 +1722,7 @@ ADD-ON COMMANDS
journal file and another.
iadd
hledger-iadd is a curses-style, more interactive replacement for the
hledger-iadd is a curses-style, more interactive replacement for the
add command.
interest
@ -1729,19 +1730,19 @@ ADD-ON COMMANDS
ing to various schemes.
irr
hledger-irr calculates the internal rate of return of an investment
hledger-irr calculates the internal rate of return of an investment
account.
Experimental add-ons
These are available in source form in the hledger repo's bin/ direc-
These are available in source form in the hledger repo's bin/ direc-
tory; installing them is pretty easy. They may be less mature and doc-
umented than built-in commands. Reading and tweaking these is a good
umented than built-in commands. Reading and tweaking these is a good
way to start making your own!
autosync
hledger-autosync is a symbolic link for easily running ledger-autosync,
if installed. ledger-autosync does deduplicating conversion of OFX
data and some CSV formats, and can also download the data if your bank
if installed. ledger-autosync does deduplicating conversion of OFX
data and some CSV formats, and can also download the data if your bank
offers OFX Direct Connect.
budget
@ -1757,18 +1758,18 @@ ADD-ON COMMANDS
hledger-check-dates.hs checks that journal entries are ordered by date.
check-dupes
hledger-check-dupes.hs checks for account names sharing the same leaf
hledger-check-dupes.hs checks for account names sharing the same leaf
name.
equity
hledger-equity.hs prints balance-resetting transactions, useful for
hledger-equity.hs prints balance-resetting transactions, useful for
bringing account balances across file boundaries.
prices
hledger-prices.hs prints all prices from the journal.
print-unique
hledger-print-unique.hs prints transactions which do not reuse an
hledger-print-unique.hs prints transactions which do not reuse an
already-seen description.
register-match
@ -1783,21 +1784,21 @@ ADD-ON COMMANDS
hledger-tags.hs Lists tag names in use.
ENVIRONMENT
COLUMNS The screen width used by the register command. Default: the
COLUMNS The screen width used by the register command. Default: the
full terminal width.
LEDGER_FILE The journal file path when not specified with -f. Default:
~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour-
~/.hledger.journal (on windows, perhaps C:/Users/USER/.hledger.jour-
nal).
FILES
Reads data from one or more files in hledger journal, timeclock, time-
dot, or CSV format specified with -f, or $LEDGER_FILE, or
$HOME/.hledger.journal (on windows, perhaps
Reads data from one or more files in hledger journal, timeclock, time-
dot, or CSV format specified with -f, or $LEDGER_FILE, or
$HOME/.hledger.journal (on windows, perhaps
C:/Users/USER/.hledger.journal).
BUGS
The need to precede addon command options with -- when invoked from
The need to precede addon command options with -- when invoked from
hledger is awkward.
When input data contains non-ascii characters, a suitable system locale
@ -1810,33 +1811,33 @@ BUGS
In a Cygwin/MSYS/Mintty window, the tab key is not supported in hledger
add.
Not all of Ledger's journal file syntax is supported. See file format
Not all of Ledger's journal file syntax is supported. See file format
differences.
On large data files, hledger is slower and uses more memory than
On large data files, hledger is slower and uses more memory than
Ledger.
TROUBLESHOOTING
Here are some issues you might encounter when you run hledger (and
remember you can also seek help from the IRC channel, mail list or bug
Here are some issues you might encounter when you run hledger (and
remember you can also seek help from the IRC channel, mail list or bug
tracker):
Successfully installed, but "No command 'hledger' found"
stack and cabal install binaries into a special directory, which should
be added to your PATH environment variable. Eg on unix-like systems,
be added to your PATH environment variable. Eg on unix-like systems,
that is ~/.local/bin and ~/.cabal/bin respectively.
I set a custom LEDGER_FILE, but hledger is still using the default file
LEDGER_FILE should be a real environment variable, not just a shell
variable. The command env | grep LEDGER_FILE should show it. You may
LEDGER_FILE should be a real environment variable, not just a shell
variable. The command env | grep LEDGER_FILE should show it. You may
need to use export. Here's an explanation.
"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
"Illegal byte sequence" or "Invalid or incomplete multibyte or wide
character" errors
In order to handle non-ascii letters and symbols (like ), hledger needs
an appropriate locale. This is usually configured system-wide; you can
also configure it temporarily. The locale may need to be one that sup-
ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
ports UTF-8, if you built hledger with GHC < 7.2 (or possibly always,
I'm not sure yet).
Here's an example of setting the locale temporarily, on ubuntu
@ -1855,7 +1856,7 @@ TROUBLESHOOTING
$ echo "export LANG=en_US.UTF-8" >>~/.bash_profile
$ bash --login
If we preferred to use eg fr_FR.utf8, we might have to install that
If we preferred to use eg fr_FR.utf8, we might have to install that
first:
$ apt-get install language-pack-fr
@ -1876,7 +1877,7 @@ TROUBLESHOOTING
REPORTING BUGS
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
Report bugs at http://bugs.hledger.org (or on the #hledger IRC channel
or hledger mail list)
@ -1890,7 +1891,7 @@ COPYRIGHT
SEE ALSO
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
hledger(1), hledger-ui(1), hledger-web(1), hledger-api(1),
hledger_csv(5), hledger_journal(5), hledger_timeclock(5), hledger_time-
dot(5), ledger(1)

View File

@ -6,29 +6,29 @@ to filter the data by date, account name or other criteria.
The syntax is similar to a web search:
one or more space-separated search terms,
quotes to enclose whitespace,
optional prefixes to match specific fields.
Multiple search terms are combined as follows:
prefixes to match specific fields,
a not: prefix to negate the match.
All commands except print:
show transactions/postings/accounts which match (or negatively match)
We do not yet support arbitrary boolean combinations of search terms;
instead most commands show transactions/postings/accounts which match (or negatively match):
- any of the description terms AND
- any of the account terms AND
- any of the status terms AND
- all the other terms.
The print command:
show transactions which
The [print](/manual.html#print) command instead shows transactions which:
- match any of the description terms AND
- have any postings matching any of the positive account terms AND
- have no postings matching any of the negative account terms AND
- match all the other terms.
The following kinds of search terms can be used:
The following kinds of search terms can be used.
Remember these can also be prefixed with **`not:`**, eg to exclude a particular subaccount.
**`REGEX`**
: match account names by this regular expression
: match account names by this regular expression. (No prefix is equivalent to `acct:`).
**`acct:REGEX`**
: same as above
@ -88,14 +88,11 @@ tag: query is considered to match a transaction if it matches any of
the postings. Also remember that postings inherit the tags of their
parent transaction.
**`not:`**
: before any of the above negates the match.
The following special search term is used only you click an account name in hledger-web:
**`inacct:ACCTNAME`**
: a special term used automatically when you click an account name in hledger-web,
specifying the account register we are currently in
(selects the transactions of that account and how to show them, can be filtered further with `acct` etc).
Not supported elsewhere in hledger.
: tells hledger-web to show the transaction register for this account.
Can be filtered further with `acct` etc.
Some of these can also be expressed as command-line options (eg `depth:2` is equivalent to `--depth 2`).
Generally you can mix options and query arguments, and the resulting query will be their intersection