relpipe-data/examples-grep-fstab.xml
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
child 325 4560c5623d7d
equal deleted inserted replaced
243:9c1d0c5ed599 244:d4f401b5f90c
       
     1 <stránka
       
     2 	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
       
     3 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
       
     4 	
       
     5 	<nadpis>Filtering /etc/fstab using relpipe-tr-grep</nadpis>
       
     6 	<perex>list only records with desired filesystem types</perex>
       
     7 	<m:pořadí-příkladu>00900</m:pořadí-příkladu>
       
     8 
       
     9 	<text xmlns="http://www.w3.org/1999/xhtml">
       
    10 		
       
    11 		<p>
       
    12 			If we are interested only in certain records in some relation, we can filter it using <code>relpipe-tr-grep</code>.
       
    13 			If we want to list e.g. only Btrfs and XFS file systems from our <code>fstab</code> (see above), we will run:
       
    14 		</p>
       
    15 		
       
    16 		
       
    17 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-tr-grep 'fstab' 'type' 'btrfs|xfs' | relpipe-out-tabular]]></m:pre>
       
    18 				
       
    19 		<p>and we will get following filtered result:</p>
       
    20 		<pre><![CDATA[fstab:
       
    21  ╭─────────────────┬──────────────────────────────────────┬──────────────────────┬───────────────┬──────────────────┬────────────────┬────────────────╮
       
    22  │ scheme (string) │ device                      (string) │ mount_point (string) │ type (string) │ options (string) │ dump (integer) │ pass (integer) │
       
    23  ├─────────────────┼──────────────────────────────────────┼──────────────────────┼───────────────┼──────────────────┼────────────────┼────────────────┤
       
    24  │ UUID            │ a2b5f230-a795-4f6f-a39b-9b57686c86d5 │ /home                │ btrfs         │ relatime         │              0 │              2 │
       
    25  │                 │ /dev/mapper/sdf_crypt                │ /mnt/private         │ xfs           │ relatime         │              0 │              2 │
       
    26  ╰─────────────────┴──────────────────────────────────────┴──────────────────────┴───────────────┴──────────────────┴────────────────┴────────────────╯
       
    27 Record count: 2]]></pre>
       
    28 
       
    29 		<p>
       
    30 			Command arguments are similar to <code>relpipe-tr-sed</code>.
       
    31 			Everything is a regular expression.
       
    32 			Only relations matching the regex will be filtered, others will flow through the pipeline unmodified.
       
    33 			If the attribute regex matches more attribute names, filtering will be done with logical OR
       
    34 			i.e. the record is included if at least one of that attributes matches the search regex.
       
    35 		</p>
       
    36 		
       
    37 		<p>
       
    38 			If we need exact match of the whole attribute, we have to use something like <code>'^btrfs|xfs$'</code>,
       
    39 			otherwise mere substring-match is enough to include the record.
       
    40 		</p>
       
    41 		
       
    42 	</text>
       
    43 
       
    44 </stránka>