table of contents
- testing 2.41.3-4
- unstable 2.41.3-4
- experimental 2.42~rc1-1
| SCOLS-FILTER(5) | Dateiformate und Konventionen | SCOLS-FILTER(5) |
BEZEICHNUNG¶
scols-filter - Syntax für libsmartcols-Filterausdrücke
SYNTAX¶
Ausdruck: param
| ( Ausdruck )
| Ausdruck && Ausdruck | Ausdruck AND Ausdruck
| Ausdruck || Ausdruck | Ausdruck OR Ausdruck
| !Ausdruck | NOT Ausdruck
| Ausdruck == Ausdruck | Ausdruck EQ Ausdruck
| Ausdruck != Ausdruck | Ausdruck NE Ausdruck
| Ausdruck >= Ausdruck | Ausdruck GE Ausdruck
| Ausdruck <= Ausdruck | Ausdruck LE Ausdruck
| Ausdruck > Ausdruck | Ausdruck GT Ausdruck
| Ausdruck < Ausdruck | Ausdruck LT Ausdruck
| Ausdruck =~ Zeichenkette
| Ausdruck !~ Zeichenkette Parameter: Ganzzahl
| Gleitkommazahl
| Zeichenkette
| Boolescher Wert
| Platzhalter Ganzzahl: [0-9]*
| [0-9]*[KMGTPEZY]
| [0-9]*[KMGTPEZY]iB Gleitkommazahl: Ganzzahl,Ganzzahl boolesch: "true" | "false" | "TRUE" | "FALSE" Zeichenkette: "[^\n\"]*" | '[^\n\']*' Platzhalter: [a-zA-Z][a-zA-Z_.%:/\-0-9]*
BESCHREIBUNG¶
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.
Der Filter kann auch für Spalten verwendet werden, die nicht für die Ausgabe vorgesehen sind.
HINWEISE ZUR SYNTAX¶
Ein Ausdruck besteht aus Platzhaltern, Parametern und Operatoren.
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".
Der Parameter »param« dient zur direkten Darstellung eines Werts. Die derzeit unterstützten Datentypen sind »integer«, »float«, »string« und »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.
Operatoren mit zwei Operanden sind »and«, »or«, »eq«, »ne«, »le«, »lt«, »ge«, »gt«, »=~« und »!~«. Alphabetisch benannte Operatoren haben C-artige Aliase: »&&«, »||«, »==«, »!=«, »<«, »⇐«, »>=« und »>«.
! 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.
Die Rangfolge innerhalb der Operatoren ist »or«, »and« und »eq«, »ne«, »le«, »gt«, »ge«, »=~«, »!~«, »not«.
BESCHRÄNKUNGEN¶
Bei Werten vom Typ »float« und »integer« unterstützt die Filter-Engine nur nichtnegative Zahlen. »integer« ist eine vorzeichenlose 64-Bit-Zahl, »float« ist eine »long double«-Zahl. Dem »integer« können die multiplikativen Suffixe KiB, GiB, TiB, PiB, EiB, ZiB und YiB folgen (das »iB« ist optional, z. B. hat »K« die gleiche Bedeutung wie »KiB«).
AUTOREN¶
Karel Zak <kzak@redhat.com>
Basierend auf der ursprünglichen Implementierung von Masatake YAMATO <yamato@redhat.com>.
FEHLER MELDEN¶
Nutzen Sie zum Melden von Fehlern das Fehlererfassungssystem <https://github.com/util-linux/util-linux/issues>.
VERFÜGBARKEIT¶
Die Bibliothek libsmartcols ist seit Version 2.25 Teil des Pakets util-linux, welches aus dem Linux-Kernel-Archiv <https://www.kernel.org/pub/linux/utils/util-linux/> heruntergeladen werden kann.
| 2026-02-28 | util-linux 2.42-rc1 |