relpipe-data/examples-grep-cut-fstab.xml
author František Kučera <franta-hg@frantovo.cz>
Tue, 27 Aug 2019 13:50:37 +0200
branchv_0
changeset 268 1b8576c9640c
parent 244 d4f401b5f90c
child 301 7029e6c47700
permissions -rw-r--r--
examples: XHTML table processing in SQL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
0d2729ed16ed zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents: 18
diff changeset
     1
<stránka
0d2729ed16ed zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents: 18
diff changeset
     2
	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
0d2729ed16ed zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents: 18
diff changeset
     3
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
0d2729ed16ed zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents: 18
diff changeset
     4
	
244
d4f401b5f90c examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents: 241
diff changeset
     5
	<nadpis>Doing projection and restriction using cut and grep</nadpis>
d4f401b5f90c examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents: 241
diff changeset
     6
	<perex>SELECT mount_point FROM fstab WHERE type IN ('btrfs', 'xfs')</perex>
d4f401b5f90c examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents: 241
diff changeset
     7
	<m:pořadí-příkladu>01000</m:pořadí-příkladu>
4
1bb39595a51c genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
     8
2
ab9099ff88fa vkládání zápatí, jmenné prostory, saxon
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
     9
	<text xmlns="http://www.w3.org/1999/xhtml">
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
    10
		
212
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    11
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    12
			While reading classic pipelines involving <code>grep</code> and <code>cut</code> commands
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    13
			we must notice that there is some similarity with simple SQL queries looking like:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    14
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    15
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    16
		<m:pre jazyk="SQL">SELECT "some", "cut", "fields" FROM stdin WHERE grep_matches(whole_line);</m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    17
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    18
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    19
			And that is true: <code>grep</code> does restriction<m:podČarou>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    20
				<a href="https://en.wikipedia.org/wiki/Selection_(relational_algebra)">selecting</a> only certain records from the original relation according to their match with given conditions</m:podČarou>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    21
			and <code>cut</code> does projection<m:podČarou>limited subset of what <a href="https://en.wikipedia.org/wiki/Projection_(relational_algebra)">projection</a> means</m:podČarou>.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    22
			Now we can do these relational operations using our relational tools called <code>relpipe-tr-grep</code> and <code>relpipe-tr-cut</code>.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    23
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    24
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    25
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    26
			Assume that we need only <code>mount_point</code> fields from our <code>fstab</code> where <code>type</code> is <code>btrfs</code> or <code>xfs</code>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    27
			and we want to do something (a shell script block) with these directory paths.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    28
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    29
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    30
		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    31
	| relpipe-tr-grep 'fstab' 'type' '^btrfs|xfs$' \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    32
	| relpipe-tr-cut 'fstab' 'mount_point' \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    33
	| relpipe-out-nullbyte \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    34
	| while read -r -d '' m; do
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    35
		echo "$m";
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    36
	done]]></m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    37
	
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    38
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    39
			The <code>relpipe-tr-cut</code> tool has similar syntax to its <em>grep</em> and <em>sed</em> siblings and also uses the power of regular expressions.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    40
			In this case it modifies on-the-fly the <code>fstab</code> relation and drops all its attributes except the <code>mount_point</code> one.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    41
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    42
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    43
		<p>
214
63f31bf2697f examples: Writing an output filter in Bash
František Kučera <franta-hg@frantovo.cz>
parents: 213
diff changeset
    44
			Then we pass the data to the Bash <code>while</code> cycle.
63f31bf2697f examples: Writing an output filter in Bash
František Kučera <franta-hg@frantovo.cz>
parents: 213
diff changeset
    45
			In such simple scenario (just <code>echo</code>), we could use <code>xargs</code> as in examples above,
212
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    46
			but in this syntax, we can write whole block of shell commands for each record/value and do more complex actions with them.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    47
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    48
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    49
		<h2>More projections with relpipe-tr-cut</h2>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    50
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    51
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    52
			Assume that we have a simple relation containing numbers:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    53
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    54
	
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    55
		<m:pre jazyk="bash"><![CDATA[seq 0 8 \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    56
	| tr \\n \\0 \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    57
	| relpipe-in-cli generate-from-stdin numbers 3 a integer b integer c integer \
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    58
	> numbers.rp]]></m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    59
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    60
		<p>and second one containing letters:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    61
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    62
		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate letters 2 a string b string A B C D > letters.rp]]></m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    63
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    64
		<p>We saved them into two files and then combined them into a single file. We will work with them as they are a single stream of relations:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    65
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    66
		<m:pre jazyk="bash"><![CDATA[cat numbers.rp letters.rp > both.rp;
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    67
cat both.rp | relpipe-out-tabular]]></m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    68
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    69
		<p>Will print:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    70
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    71
		<pre><![CDATA[numbers:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    72
 ╭─────────────┬─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    73
 │ a (integer) │ b (integer) │ c (integer) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    74
 ├─────────────┼─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    75
 │           0 │           1 │           2 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    76
 │           3 │           4 │           5 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    77
 │           6 │           7 │           8 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    78
 ╰─────────────┴─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    79
Record count: 3
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    80
letters:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    81
 ╭─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    82
 │ a  (string) │ b  (string) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    83
 ├─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    84
 │ A           │ B           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    85
 │ C           │ D           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    86
 ╰─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    87
Record count: 2]]></pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    88
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    89
		<p>We can put away the <code>a</code> attribute from the <code>numbers</code> relation:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    90
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    91
		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|c' | relpipe-out-tabular</m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    92
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    93
		<p>and leave the <code>letters</code> relation unaffected:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    94
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    95
		<pre><![CDATA[numbers:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    96
 ╭─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    97
 │ b (integer) │ c (integer) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    98
 ├─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
    99
 │           1 │           2 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   100
 │           4 │           5 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   101
 │           7 │           8 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   102
 ╰─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   103
Record count: 3
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   104
letters:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   105
 ╭─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   106
 │ a  (string) │ b  (string) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   107
 ├─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   108
 │ A           │ B           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   109
 │ C           │ D           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   110
 ╰─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   111
Record count: 2]]></pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   112
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   113
		<p>Or we can remove <code>a</code> from both relations resp. keep there only attributes whose names match <code>'b|c'</code> regex:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   114
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   115
		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut '.*' 'b|c' | relpipe-out-tabular</m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   116
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   117
		<p>Instead of <code>'.*'</code> we could use <code>'numbers|letters'</code> and in this case it will give the same result:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   118
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   119
		<pre><![CDATA[numbers:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   120
 ╭─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   121
 │ b (integer) │ c (integer) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   122
 ├─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   123
 │           1 │           2 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   124
 │           4 │           5 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   125
 │           7 │           8 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   126
 ╰─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   127
Record count: 3
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   128
letters:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   129
 ╭─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   130
 │ b  (string) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   131
 ├─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   132
 │ B           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   133
 │ D           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   134
 ╰─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   135
Record count: 2]]></pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   136
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   137
		<p>All the time, we are reducing the attributes. But we can also multiply them or change their order:</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   138
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   139
		<m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|a|c' 'b' 'a' 'a' | relpipe-out-tabular</m:pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   140
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   141
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   142
			n.b. the order in <code>'b|a|c'</code> does not matter and if such regex matches, it preserves the original order of the attributes;
213
cbf25a63a43f specification: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 212
diff changeset
   143
			but if we use multiple regexes to specify attributes, their order and count matters:
212
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   144
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   145
		
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   146
		<pre><![CDATA[numbers:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   147
 ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   148
 │ a (integer) │ b (integer) │ c (integer) │ b (integer) │ a (integer) │ a (integer) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   149
 ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   150
 │           0 │           1 │           2 │           1 │           0 │           0 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   151
 │           3 │           4 │           5 │           4 │           3 │           3 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   152
 │           6 │           7 │           8 │           7 │           6 │           6 │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   153
 ╰─────────────┴─────────────┴─────────────┴─────────────┴─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   154
Record count: 3
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   155
letters:
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   156
 ╭─────────────┬─────────────╮
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   157
 │ a  (string) │ b  (string) │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   158
 ├─────────────┼─────────────┤
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   159
 │ A           │ B           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   160
 │ C           │ D           │
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   161
 ╰─────────────┴─────────────╯
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   162
Record count: 2]]></pre>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   163
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   164
		<p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   165
			The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut 'numbers'</code> does not affect it in any way.
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   166
		</p>
bf9a704dc916 examples: relpipe-tr-cut
František Kučera <franta-hg@frantovo.cz>
parents: 210
diff changeset
   167
		
87
25dec6931f18 Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents: 23
diff changeset
   168
	</text>
4
1bb39595a51c genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   169
1
a05c6f3cbc3e základ, první verze
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   170
</stránka>