Scroll to navigation

SCOLS-FILTER(5) Formate de fișiere și convenții SCOLS-FILTER(5)

NUME

scols-filter - sintaxa pentru expresiile de filtrare libsmartcols

SINTAXĂ

expr: param

| ( expr )
| expr && expr | expr AND expr
| expr || expr | expr OR expr
| !expr | NOT expr
| expr == expr | expr EQ expr
| expr != expr | expr NE expr
| expr >= expr | expr GE expr
| expr <= expr | expr LE expr
| expr > expr | expr GT expr
| expr < expr | expr LT expr
| expr =~ șir
| expr !~ șir param: integer
| float
| șir
| boolean
| holder integer: [0-9]*
| [0-9]*[KMGTPEZY]
| [0-9]*[KMGTPEZY]iB float: integer.integer boolean: "true" | "false" | "TRUE" | "FALSE" șir: "[^\n\"]*" | '[^\n\']*' holder: [a-zA-Z][a-zA-Z_.%:/\-0-9]*

DESCRIERE

The filter expression can be used by application linked with libsmartcols to filter output data. The application can use the filter before it gathers all data for the output to reduce resources and improve performance. This makes scols filter more effective than grep(1) on the complete output. For example


lsblk --output NAME,LABEL,FSTYPE --filter 'NAME=="sda1"'

helps lsblk(1) to not read LABELs for all block device from udevd or libblkid, but read it only for device sda1.

Filtrul poate fi utilizat și pentru coloanele care nu sunt utilizate în ieșire.

NOTE SINTAXĂ

O expresie constă din titulari(holders), parametri și operatori.

The currently supported holder type is column name only. The name has to be used without quotes. Before evaluation, application maps column names in the given expression to the output table columns and assign column data type to the holder. The default type is "string".

Parametrul „param” este destinat reprezentării directe a unei valori. Tipurile de date acceptate în prezent sunt „integer”, „float”, „string” și „boolean”.

An operator works with one or two operand(s). An operator has an expectation about the data type(s) of its operands. Giving an unexpected data type to an operator causes a syntax error. The library can cast between data types, the preferred is always the type as specified by param and in case of expression with number and float the preferred is the float.

Operatorii care acceptă doi operanzi sunt „and”, „or”, „eq”, „ne”, „le”, „lt”, „ge”, „gt”, „=~”, „!~”. Operatorii numiți alfabetic au un alias în limbaj C: „&&”, „||”, „==”, „!=”, „<”, „⇐”, „>=” și „>”.

! is the only operator that takes one operand. If no operator is specified then expression is true if param or holder are not empty. For example --filter NAME will return lines where column NAME is not empty.

=~ and !~ is for regular expression matching; if a string at the right side matches (or not matches for !~ a regular expression at the left side), the result is true. The right side operand must be a string literal.

Prioritatea operatorilor este „or”, „and” și „eq”, „ne”, „le”, „gt”, „ge”, „=~”, „!~”, „not”.

LIMITĂRI

În ceea ce privește valorile tip „float” și „integer”, motorul de filtrare acceptă numai numere ne-negative. „integer” este un număr pe 64 de biți fără semn, iar „float” este un număr dublu lung. „integer” poate fi urmat de sufixele multiplicative KiB, GiB, TiB, PiB, EiB, ZiB și YiB („iB” este opțional, de exemplu, „K” are aceeași semnificație ca „KiB”).

AUTORI

Karel Zak <kzak@redhat.com>

Pe baza implementării inițiale de la Masatake YAMATO <yamato@redhat.com>

RAPORTAREA ERORILOR

Pentru rapoarte de eroare, folosiți sistemul de urmărire al erorilor <https://github.com/util-linux/util-linux/issues>.

DISPONIBILITATE

Biblioteca libsmartcols face parte din pachetul util-linux începând cu versiunea 2.25. Acesta poate fi descărcat de la Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.

2026-02-28 util-linux 2.42-rc1