Debian Codegraph @

libsmartcols/scols-filter.5

raw
1 '\" t
2 .\" Title: scols-filter
3 .\" Author: [see the "AUTHOR(S)" section]
4 .\" Generator: Asciidoctor 2.0.20
5 .\" Date: 2026-04-28
6 .\" Manual: File formats and conventions
7 .\" Source: util-linux 2.42.1
8 .\" Language: English
9 .\"
10 .TH "SCOLS\-FILTER" "5" "2026-04-28" "util\-linux 2.42.1" "File formats and conventions"
11 .ie \n(.g .ds Aq \(aq
12 .el .ds Aq '
13 .ss \n[.ss] 0
14 .nh
15 .ad l
16 .de URL
17 \fI\\$2\fP <\\$1>\\$3
18 ..
19 .als MTO URL
20 .if \n[.g] \{\
21 . mso www.tmac
22 . am URL
23 . ad l
24 . .
25 . am MTO
26 . ad l
27 . .
28 . LINKSTYLE blue R < >
29 .\}
30 .SH "NAME"
31 scols-filter \- syntax for libsmartcols filter expressions
32 .SH "SYNTAX"
33 .sp
34 .if n .RS 4
35 .nf
36 .fam C
37 expr: param
38 | ( expr )
39 | expr && expr | expr AND expr
40 | expr || expr | expr OR expr
41 | !expr | NOT expr
42 | expr == expr | expr EQ expr
43 | expr != expr | expr NE expr
44 | expr >= expr | expr GE expr
45 | expr <= expr | expr LE expr
46 | expr > expr | expr GT expr
47 | expr < expr | expr LT expr
48 | expr =~ string
49 | expr !~ string
50
51 param: integer
52 | float
53 | string
54 | boolean
55 | holder
56
57 integer: [0\-9]*
58 | [0\-9]*[KMGTPEZY]
59 | [0\-9]*[KMGTPEZY]iB
60
61 float: integer.integer
62
63 boolean: "true" | "false" | "TRUE" | "FALSE"
64
65 string: "[^\(rsn\(rs"]*" | \*(Aq[^\(rsn\(rs\*(Aq]*\*(Aq
66
67 holder: [a\-zA\-Z][a\-zA\-Z_.%:/\(rs\-0\-9]*
68 .fam
69 .fi
70 .if n .RE
71 .SH "DESCRIPTION"
72 .sp
73 The filter expression can be used by application linked with libsmartcols to filter
74 output data. The application can use the filter before it gathers all data for the
75 output to reduce resources and improve performance. This makes scols filter more
76 effective than \fBgrep\fP(1) on the complete output. For example
77 .sp
78 .if n .RS 4
79 .nf
80 .fam C
81 lsblk \-\-output NAME,LABEL,FSTYPE \-\-filter \*(AqNAME=="sda1"\*(Aq
82 .fam
83 .fi
84 .if n .RE
85 .sp
86 helps \fBlsblk\fP(1) to not read LABELs for all block device from udevd or libblkid,
87 but read it only for device sda1.
88 .sp
89 The filter can be also used for columns which are not used in the output.
90 .SH "SYNTAX NOTES"
91 .sp
92 An expression consists of holders, params, and operators.
93 .sp
94 The currently supported \f(CRholder\fP type is column name only. The name has to be
95 used without quotes. Before evaluation, application maps column names in the
96 given expression to the output table columns and assign column data type to the
97 holder. The default type is "string".
98 .sp
99 The \f(CRparam\fP is for representing a value directly. The currently supported data
100 types are integer, float, string and boolean.
101 .sp
102 An operator works with one or two operand(s). An operator has an expectation
103 about the data type(s) of its operands. Giving an unexpected data type to an
104 operator causes a syntax error. The library can cast between data types, the
105 preferred is always the type as specified by \f(CRparam\fP and in case of expression with
106 number and float the preferred is the float.
107 .sp
108 Operators taking two operands are \f(CRand\fP, \f(CRor\fP, \f(CReq\fP, \f(CRne\fP, \f(CRle\fP, \f(CRlt\fP, \f(CRge\fP, \f(CRgt\fP, \f(CR=~\fP, \f(CR!~\fP.
109 Alphabetically named operators have C\-language
110 flavored aliases: \f(CR&&\fP, \f(CR||\fP, \f(CR==\fP, \f(CR!=\fP, \f(CR<\fP, \f(CR\(lA\fP, \f(CR>=\fP, and \f(CR>\fP.
111 .sp
112 \f(CR!\fP is the only operator that takes one operand. If no operator is specified then
113 expression is true if param or holder are not empty. For example \fB\-\-filter NAME\fP will
114 return lines where column NAME is not empty.
115 .sp
116 \f(CR=~\fP and \f(CR!~\fP is for regular expression matching; if a string at the right side
117 matches (or not matches for \f(CR!~\fP a regular expression at the left side), the result
118 is true. The right side operand must be a string literal.
119 .sp
120 The precedences within operators is \f(CRor\fP, \f(CRand\fP, and \f(CReq\fP, \f(CRne\fP, \f(CRle\fP, \f(CRgt\fP, \f(CRge\fP, \f(CR=~\fP, \f(CR!~\fP, \f(CRnot\fP.
121 .SH "LIMITATIONS"
122 .sp
123 About \f(CRfloat\fP and \f(CRinteger\fP typed values, the filter engine supports only
124 non\-negative numbers. The \f(CRinteger\fP is unsigned 64\-bit number, and \f(CRfloat\fP is
125 long double. The \f(CRinteger\fP may be followed by the multiplicative suffixes KiB,
126 GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is optional, e.g., "K" has the same
127 meaning as "KiB").
128 .SH "AUTHORS"
129 .sp
130 .MTO "kzak\(atredhat.com" "Karel Zak" ""
131 .sp
132 Based on original implementation from \c
133 .MTO "yamato\(atredhat.com" "Masatake YAMATO" "."
134 .SH "REPORTING BUGS"
135 .sp
136 For bug reports, use the \c
137 .URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "."
138 .SH "AVAILABILITY"
139 .sp
140 The \fBlibsmartcols\fP library is part of the util\-linux package since version 2.25. It can be downloaded from \c
141 .URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."