relpipe-data/examples.xml
branchv_0
changeset 208 91a210d3b66a
parent 207 4e45b9a177c2
child 209 74fecc2ba590
equal deleted inserted replaced
207:4e45b9a177c2 208:91a210d3b66a
   381 		
   381 		
   382 		<pre>/dev/alpha/photos    /mnt/photos/    btrfs    noauto,noatime,nodiratime    0  0</pre>
   382 		<pre>/dev/alpha/photos    /mnt/photos/    btrfs    noauto,noatime,nodiratime    0  0</pre>
   383 		
   383 		
   384 		<p>
   384 		<p>
   385 			We want to change all lines from <code>alpha</code> to <code>beta</code> (the new VG name).
   385 			We want to change all lines from <code>alpha</code> to <code>beta</code> (the new VG name).
   386 			This can be done by:
   386 			This can be done by the power of regular expressions<m:podČarou>see <a href="https://en.wikibooks.org/wiki/Regular_Expressions/Simple_Regular_Expressions">Regular Expressions</a> at Wikibooks</m:podČarou> and this pipeline:
   387 		</p>
   387 		</p>
   388 		
   388 		
   389 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
   389 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
   390 	| relpipe-tr-sed 'fstab' 'device' '^/dev/alpha/' '/dev/beta/' \
   390 	| relpipe-tr-sed 'fstab' 'device' '^/dev/alpha/' '/dev/beta/' \
   391 	| relpipe-out-fstab]]></m:pre>
   391 	| relpipe-out-fstab]]></m:pre>
   438 		<p>
   438 		<p>
   439 			If there were any other relations or attributes in the stream, they would be unaffected by this transformation,
   439 			If there were any other relations or attributes in the stream, they would be unaffected by this transformation,
   440 			becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes.
   440 			becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes.
   441 		</p>
   441 		</p>
   442 		
   442 		
       
   443 		<h2>Filter /etc/fstab using relpipe-tr-grep</h2>
       
   444 		
       
   445 		<p>
       
   446 			If we are interested only in certain records in some relation, we can filter it using <code>relpipe-tr-grep</code>.
       
   447 			If we want to list e.g. only Btrfs and XFS file systems from our <code>fstab</code> (see above), we will run:
       
   448 		</p>
       
   449 		
       
   450 		
       
   451 		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-tr-grep 'fstab' 'type' 'btrfs|xfs' | relpipe-out-tabular]]></m:pre>
       
   452 				
       
   453 		<p>and we will get following filtered result:</p>
       
   454 		<pre><![CDATA[fstab:
       
   455  ╭─────────────────┬──────────────────────────────────────┬──────────────────────┬───────────────┬──────────────────┬────────────────┬────────────────╮
       
   456  │ scheme (string) │ device                      (string) │ mount_point (string) │ type (string) │ options (string) │ dump (integer) │ pass (integer) │
       
   457  ├─────────────────┼──────────────────────────────────────┼──────────────────────┼───────────────┼──────────────────┼────────────────┼────────────────┤
       
   458  │ UUID            │ a2b5f230-a795-4f6f-a39b-9b57686c86d5 │ /home                │ btrfs         │ relatime         │              0 │              2 │
       
   459  │                 │ /dev/mapper/sdf_crypt                │ /mnt/private         │ xfs           │ relatime         │              0 │              2 │
       
   460  ╰─────────────────┴──────────────────────────────────────┴──────────────────────┴───────────────┴──────────────────┴────────────────┴────────────────╯
       
   461 Record count: 2]]></pre>
       
   462 
       
   463 		<p>
       
   464 			Command arguments are similar to <code>relpipe-tr-sed</code>.
       
   465 			Everything is a regular expression.
       
   466 			Only relations matching the regex will be filtered, others will flow through the pipeline unmodified.
       
   467 			If the attribute regex matches more attribute names, filtering will be done with logical OR
       
   468 			i.e. the record is included if at least one of that attributes matches the search regex.
       
   469 		</p>
       
   470 		
       
   471 		<p>
       
   472 			If we need exact match of the whole attribute, we have to use something like <code>'^btrfs|xfs$'</code>,
       
   473 			otherwise mere substring-match is enough to include the record.
       
   474 		</p>
       
   475 		
   443 	</text>
   476 	</text>
   444 
   477 
   445 </stránka>
   478 </stránka>