relpipe-data/examples-grep-fstab.xml
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
child 325 4560c5623d7d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-grep-fstab.xml	Tue Feb 05 19:18:28 2019 +0100
@@ -0,0 +1,44 @@
+<stránka
+	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
+	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
+	
+	<nadpis>Filtering /etc/fstab using relpipe-tr-grep</nadpis>
+	<perex>list only records with desired filesystem types</perex>
+	<m:pořadí-příkladu>00900</m:pořadí-příkladu>
+
+	<text xmlns="http://www.w3.org/1999/xhtml">
+		
+		<p>
+			If we are interested only in certain records in some relation, we can filter it using <code>relpipe-tr-grep</code>.
+			If we want to list e.g. only Btrfs and XFS file systems from our <code>fstab</code> (see above), we will run:
+		</p>
+		
+		
+		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-tr-grep 'fstab' 'type' 'btrfs|xfs' | relpipe-out-tabular]]></m:pre>
+				
+		<p>and we will get following filtered result:</p>
+		<pre><![CDATA[fstab:
+ ╭─────────────────┬──────────────────────────────────────┬──────────────────────┬───────────────┬──────────────────┬────────────────┬────────────────╮
+ │ scheme (string) │ device                      (string) │ mount_point (string) │ type (string) │ options (string) │ dump (integer) │ pass (integer) │
+ ├─────────────────┼──────────────────────────────────────┼──────────────────────┼───────────────┼──────────────────┼────────────────┼────────────────┤
+ │ UUID            │ a2b5f230-a795-4f6f-a39b-9b57686c86d5 │ /home                │ btrfs         │ relatime         │              0 │              2 │
+ │                 │ /dev/mapper/sdf_crypt                │ /mnt/private         │ xfs           │ relatime         │              0 │              2 │
+ ╰─────────────────┴──────────────────────────────────────┴──────────────────────┴───────────────┴──────────────────┴────────────────┴────────────────╯
+Record count: 2]]></pre>
+
+		<p>
+			Command arguments are similar to <code>relpipe-tr-sed</code>.
+			Everything is a regular expression.
+			Only relations matching the regex will be filtered, others will flow through the pipeline unmodified.
+			If the attribute regex matches more attribute names, filtering will be done with logical OR
+			i.e. the record is included if at least one of that attributes matches the search regex.
+		</p>
+		
+		<p>
+			If we need exact match of the whole attribute, we have to use something like <code>'^btrfs|xfs$'</code>,
+			otherwise mere substring-match is enough to include the record.
+		</p>
+		
+	</text>
+
+</stránka>