Debian Codegraph @

libsmartcols/scols-filter.5.adoc

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