]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libsmartcols/scols-filter.5.adoc
Merge branch 'PR/ipcs-fix-counters' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / libsmartcols / scols-filter.5.adoc
CommitLineData
da12f191
KZ
1//po4a: entry man manual
2////
3Copyright (C) 2023 Karel Zak <kzak@redhat.com>
4
5This file may be copied under the terms of the GNU Public License.
6////
7= scols-filter(5)
8:doctype: manpage
9:man manual: File formats and conventions
10:man source: util-linux {release-version}
11:page-layout: base
12:lib: libsmartcols
13:firstversion: 2.25
14:colon: :
15
16== NAME
17
18scols-filter - syntax for libsmartcols filter expressions
19
20== SYNTAX
21// Simplified https://en.wikipedia.org/wiki/Wirth_syntax_notation
22// TRANSLATORS: don't translate the expressions syntax, please.
23[verse]
24----
25expr: param
26 | ( expr )
27 | expr && expr | expr AND expr
28 | expr || expr | expr OR expr
29 | !expr | NOT expr
30 | expr == expr | expr EQ expr
31 | expr != expr | expr NE expr
32 | expr >= expr | expr GE expr
33 | expr <= expr | expr LE expr
34 | expr > expr | expr GT expr
35 | expr < expr | expr LT expr
36 | expr =~ string
37 | expr !~ string
38
39param: integer
40 | float
41 | string
42 | boolean
43 | holder
44
45integer: [0-9]*
46
47float: integer.integer
48
49boolean: "true" | "false" | "TRUE" | "FALSE"
50
51string: "[^\n\"]*" | '[^\n\']*'
52
53holder: [a-zA-Z][a-zA-Z_.%:/\-0-9]*
54----
55
56== DESCRIPTION
57
58The filter expression can be used by application linked with libsmartcols to filter
59output data. The application can use the filter before it gathers all data for the
60output to reduce resources and improve performance. This makes scols filter more
61effective than grep(1) on the complete output. For example
62....
63 lsblk --output NAME,LABEL,FSTYPE --filter 'NAME=="sda1"'
64....
65helps lsblk(1) to not read LABELs for all block device from udevd or libblkid,
66but read it only for device sda1.
67
68The filter can be also used for columns which are not used in the output.
69
70== SYNTAX NOTES
71
72An expression consists of holders, params, and operators.
73
74The currently supported `holder` type is column name only. The name has to be
75used without quotes. Before evaluation, application map column names in the
76given expression to the output table columns and assign column data type to the
77holder. The default type is "string".
78
79The `param` is for representing a value directly. The currenly supported data
80types are integer, float, string and boolean.
81
82An operator works with one or two operand(s). An operator has an expectation
83about the data type(s) of its operands. Giving an unexpected data type to an
84operator causes a syntax error. The library can cast between data types, the
885ad817
MY
85prefferred is always the type as specified by `param` and in case of expression with
86number and float the preferred is the float.
da12f191
KZ
87
88Operators taking two operands are `and`, `or`, `eq`, `ne`, `le`, `lt`, `ge`, `gt`, `=~`, `!~`.
89Alphabetically named operators have C-language
90flavored aliases: `&&`, `||`, `==`, `!=`, `<`, `<=`, `>=`, and `>`.
91
92`!` is the only operator that takes one operand. If no operator is specified then
93expression is true if param or holder are not empty. For example `--filter NAME` will
94return lines where column NAME is not empty.
95
96`=~` and `!~` is for regular expression matching; if a string at the right side
97matches (or not matches for `!~` a regular expression at the left side, the result
98is true. The right side operand must be a string literal.
99
100The precedences within operators is `or`, `and`, and `eq`, `ne`, `le`, `gt`, `ge`, `=~`, `!~`, `not`.
101
102== LIMITATIONS
103
104About `float` and `integer` typed values, the filter engine supports only
105non-negative numbers. The `integer` is unsigned 64-bit number, and `float` is
106long double.
107
108
109== AUTHORS
110
111mailto:kzak@redhat.com[Karel Zak]
112
113Based on original implementation from mailto:yamato@redhat.com[Masatake YAMATO].
114
115include::man-common/bugreports.adoc[]
116
117include::man-common/footer-lib.adoc[]
118
119ifdef::translation[]
120include::man-common/translation.adoc[]
121endif::[]