relpipe-data/examples-grep-fstab.xml
author František Kučera <franta-hg@frantovo.cz>
Mon, 27 Jul 2020 16:17:41 +0200
branchv_0
changeset 308 0c5723bc16bc
parent 244 d4f401b5f90c
child 325 4560c5623d7d
permissions -rw-r--r--
template: diagram macro: remove localized alt/title

<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>