relpipe-data/examples.xml
author František Kučera <franta-hg@frantovo.cz>
Mon, 10 Dec 2018 19:43:48 +0100
branchv_0
changeset 207 4e45b9a177c2
parent 198 48a3c1c8c411
child 208 91a210d3b66a
permissions -rw-r--r--
examples: relpipe-tr-sed
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
	
140
1d8a3f7ec393 create empty pages
František Kučera <franta-hg@frantovo.cz>
parents: 139
diff changeset
     5
	<nadpis>Examples</nadpis>
1d8a3f7ec393 create empty pages
František Kučera <franta-hg@frantovo.cz>
parents: 139
diff changeset
     6
	<perex>Usage examples of Relational pipes tools</perex>
1d8a3f7ec393 create empty pages
František Kučera <franta-hg@frantovo.cz>
parents: 139
diff changeset
     7
	<pořadí>40</pořadí>
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
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
    11
		
198
48a3c1c8c411 examples: they were tested in GNU Bash
František Kučera <franta-hg@frantovo.cz>
parents: 196
diff changeset
    12
		<p>
48a3c1c8c411 examples: they were tested in GNU Bash
František Kučera <franta-hg@frantovo.cz>
parents: 196
diff changeset
    13
			All examples were tested in <a href="https://www.gnu.org/software/bash/">GNU Bash</a>.
48a3c1c8c411 examples: they were tested in GNU Bash
František Kučera <franta-hg@frantovo.cz>
parents: 196
diff changeset
    14
			But they should also work in other shells.
48a3c1c8c411 examples: they were tested in GNU Bash
František Kučera <franta-hg@frantovo.cz>
parents: 196
diff changeset
    15
		</p>
48a3c1c8c411 examples: they were tested in GNU Bash
František Kučera <franta-hg@frantovo.cz>
parents: 196
diff changeset
    16
		
185
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    17
		<h3>relpipe-in-cli: Hello Wordl!</h3>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    18
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    19
		<p>
195
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
    20
			Let's start with an obligatory Hello World example.
185
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    21
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    22
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    23
		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate "relation_from_cli" 3 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    24
	"a" "integer" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    25
	"b" "string" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    26
	"c" "boolean" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    27
	"1" "Hello" "true" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    28
	"2" "World!" "false"]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    29
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    30
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    31
			This command generates relational data.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    32
			In order to see them, we need to convert them to some other format.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    33
			For now, we will use the "tabular" format and pipe relational data to the <code>relpipe-out-tabular</code>.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    34
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    35
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    36
		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate "relation_from_cli" 3 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    37
		"a" "integer" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    38
		"b" "string" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    39
		"c" "boolean" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    40
		"1" "Hello" "true" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    41
		"2" "World!" "false" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    42
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    43
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    44
		<p>Output:</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    45
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    46
		<pre><![CDATA[relation_from_cli:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    47
 ╭─────────────┬────────────┬─────────────╮
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    48
 │ a (integer) │ b (string) │ c (boolean) │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    49
 ├─────────────┼────────────┼─────────────┤
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    50
 │           1 │ Hello      │        true │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    51
 │           2 │ World!     │       false │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    52
 ╰─────────────┴────────────┴─────────────╯
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    53
Record count: 2
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    54
]]></pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    55
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    56
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    57
			The syntax is simple as we see above. We specify the name of the relation, number of attributes,
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    58
			and then their definitions (names and types),
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    59
			followed by the data.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    60
		</p>
196
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    61
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    62
		<p>
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    63
			A single stream may contain multiple relations:
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    64
		</p>		
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    65
		
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    66
		<m:pre jazyk="bash"><![CDATA[(relpipe-in-cli generate a 1 x string hello; \
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    67
 relpipe-in-cli generate b 1 y string world) \
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    68
	| relpipe-out-tabular]]></m:pre>
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    69
			
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    70
		<p>
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    71
			Thus we can combine various commands or files and pass the result to a single relational output filter (<code>relpipe-out-tabular</code> in this case) and get:
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    72
		</p>
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    73
		
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    74
		<pre><![CDATA[a:
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    75
 ╭────────────╮
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    76
 │ x (string) │
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    77
 ├────────────┤
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    78
 │ hello      │
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    79
 ╰────────────╯
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    80
Record count: 1
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    81
b:
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    82
 ╭────────────╮
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    83
 │ y (string) │
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    84
 ├────────────┤
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    85
 │ world      │
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    86
 ╰────────────╯
8dd5b7ecb736 examples: multiple relations in a single stream
František Kučera <franta-hg@frantovo.cz>
parents: 195
diff changeset
    87
Record count: 1]]></pre>
185
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    88
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    89
		<h3>relpipe-in-cli: STDIN</h3>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    90
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    91
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    92
			The number of CLI arguments is limited and their are passed at once to the process.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    93
			So there is option to pass the values from STDIN instead of CLI arguments.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    94
			Values on STDIN are expected to be separated by the null-byte.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    95
			We can generate such data e.g. using <code>echo</code> and <code>tr</code> (or using <code>printf</code> or other commands):
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    96
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    97
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    98
		<m:pre jazyk="bash"><![CDATA[echo -e "1\nHello\ntrue\n2\nWorld\nfalse" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    99
	| tr \\n \\0 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   100
	| relpipe-in-cli generate-from-stdin relation_from_stdin 3 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   101
		a integer \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   102
		b string \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   103
		c boolean \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   104
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   105
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   106
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   107
			The output is same as above.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   108
			We can use this approach to convert various formats to relational data.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   109
			There are lot of data already in the form of null-separated values e.g. the process arguments:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   110
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   111
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   112
		<m:pre jazyk="bash"><![CDATA[cat /proc/$(pidof mc)/cmdline \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   113
	| relpipe-in-cli generate-from-stdin mc_args 1 a string \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   114
	| relpipe-out-tabular
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   115
]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   116
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   117
		<p>If we have <code>mc /etc/ /tmp/</code> running in some other terminal, the output will be:</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   118
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   119
		<pre><![CDATA[mc_args:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   120
 ╭────────────╮
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   121
 │ a (string) │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   122
 ├────────────┤
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   123
 │ mc         │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   124
 │ /etc/      │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   125
 │ /tmp/      │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   126
 ╰────────────╯
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   127
Record count: 3]]></pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   128
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   129
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   130
			Also the <code>find</code> command can produce data separated by the null-byte:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   131
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   132
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   133
		<m:pre jazyk="bash"><![CDATA[find /etc/ -name '*ssh*_*' -print0 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   134
	| relpipe-in-cli generate-from-stdin files 1 file_name string \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   135
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   136
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   137
		<p>Will display something like this:</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   138
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   139
		<pre><![CDATA[files:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   140
 ╭───────────────────────────────────╮
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   141
 │ file_name                (string) │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   142
 ├───────────────────────────────────┤
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   143
 │ /etc/ssh/ssh_host_ecdsa_key       │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   144
 │ /etc/ssh/sshd_config              │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   145
 │ /etc/ssh/ssh_host_ed25519_key.pub │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   146
 │ /etc/ssh/ssh_host_ecdsa_key.pub   │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   147
 │ /etc/ssh/ssh_host_rsa_key         │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   148
 │ /etc/ssh/ssh_config               │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   149
 │ /etc/ssh/ssh_host_ed25519_key     │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   150
 │ /etc/ssh/ssh_import_id            │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   151
 │ /etc/ssh/ssh_host_rsa_key.pub     │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   152
 ╰───────────────────────────────────╯
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   153
Record count: 9]]></pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   154
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   155
		
186
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   156
		<h3>relpipe-in-fstab</h3>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   157
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   158
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   159
			Using command <code>relpipe-in-fstab</code> we can convert the <code>/etc/fstab</code> or <code>/etc/mtab</code> to relational data 
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   160
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   161
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   162
		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-out-tabular]]></m:pre>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   163
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   164
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   165
			and see them as a nice table:
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   166
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   167
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   168
		<pre><![CDATA[fstab:
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   169
 ╭─────────────────┬──────────────────────────────────────┬──────────────────────┬───────────────┬───────────────────────────────────────┬────────────────┬────────────────╮
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   170
 │ scheme (string) │ device                      (string) │ mount_point (string) │ type (string) │ options                      (string) │ dump (integer) │ pass (integer) │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   171
 ├─────────────────┼──────────────────────────────────────┼──────────────────────┼───────────────┼───────────────────────────────────────┼────────────────┼────────────────┤
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   172
 │ UUID            │ 29758270-fd25-4a6c-a7bb-9a18302816af │ /                    │ ext4          │ relatime,user_xattr,errors=remount-ro │              0 │              1 │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   173
 │                 │ /dev/sr0                             │ /media/cdrom0        │ udf,iso9660   │ user,noauto                           │              0 │              0 │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   174
 │                 │ /dev/sde                             │ /mnt/data            │ ext4          │ relatime,user_xattr,errors=remount-ro │              0 │              2 │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   175
 │ UUID            │ a2b5f230-a795-4f6f-a39b-9b57686c86d5 │ /home                │ btrfs         │ relatime                              │              0 │              2 │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   176
 │                 │ /dev/mapper/sdf_crypt                │ /mnt/private         │ xfs           │ relatime                              │              0 │              2 │
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   177
 ╰─────────────────┴──────────────────────────────────────┴──────────────────────┴───────────────┴───────────────────────────────────────┴────────────────┴────────────────╯
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   178
Record count: 5]]></pre>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   179
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   180
		<p>And we can do the same also with a remote <code>fstab</code> or <code>mtab</code>; just by adding <code>ssh</code> to the pipeline:</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   181
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   182
		<m:pre jazyk="bash"><![CDATA[ssh example.com cat /etc/mtab | relpipe-in-fstab | relpipe-out-tabular]]></m:pre>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   183
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   184
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   185
			The <code>cat</code> runs remotely. The <code>relpipe-in-fstab</code> and <code>relpipe-out-tabular</code> run on our machine.
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   186
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   187
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   188
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   189
			n.b. the <code>relpipe-in-fstab</code> reads the <code>/etc/fstab</code> if executed on TTY. Otherwise, it reads the STDIN.
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   190
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   191
		
187
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   192
		<h3>relpipe-out-xml</h3>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   193
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   194
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   195
			Relational data can be converted to various formats and one of them is the XML.
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   196
			This is a good option for further processing e.g. using XSLT transformation or passing the XML data to some other tool.
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   197
			Just use <code>relpipe-out-xml</code> instead of <code>relpipe-out-tabular</code> and the rest of the pipeline remains unchanged:
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   198
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   199
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   200
		<m:pre jazyk="bash"><![CDATA[ssh example.com cat /etc/mtab | relpipe-in-fstab | relpipe-out-xml]]></m:pre>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   201
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   202
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   203
			Will produce XML like this:
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   204
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   205
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   206
		<m:pre jazyk="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   207
<pipe>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   208
	<relation>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   209
		<name>fstab</name>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   210
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   211
			<attribute>UUID</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   212
			<attribute>29758270-fd25-4a6c-a7bb-9a18302816af</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   213
			<attribute>/</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   214
			<attribute>ext4</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   215
			<attribute>relatime,user_xattr,errors=remount-ro</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   216
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   217
			<attribute>1</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   218
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   219
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   220
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   221
			<attribute>/dev/sr0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   222
			<attribute>/media/cdrom0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   223
			<attribute>udf,iso9660</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   224
			<attribute>user,noauto</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   225
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   226
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   227
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   228
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   229
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   230
			<attribute>/dev/sde</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   231
			<attribute>/mnt/data</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   232
			<attribute>ext4</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   233
			<attribute>relatime,user_xattr,errors=remount-ro</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   234
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   235
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   236
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   237
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   238
			<attribute>UUID</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   239
			<attribute>a2b5f230-a795-4f6f-a39b-9b57686c86d5</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   240
			<attribute>/home</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   241
			<attribute>btrfs</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   242
			<attribute>relatime</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   243
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   244
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   245
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   246
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   247
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   248
			<attribute>/dev/mapper/sdf_crypt</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   249
			<attribute>/mnt/private</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   250
			<attribute>xfs</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   251
			<attribute>relatime</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   252
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   253
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   254
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   255
	</relation>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   256
</pipe>]]></m:pre>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   257
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   258
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   259
			Thanks to XSLT, this XML can be easily converted e.g. to an XHTML table (<code>table|tr|td</code>) or other format.
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   260
			Someone can convert such data to a (La)TeX table.
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   261
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   262
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   263
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   264
			n.b. the format is not final and will change i future versions (XML namespace, more metadata etc.).
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   265
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   266
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   267
		
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   268
		<h3>relpipe-tr-validator</h3>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   269
		
2
ab9099ff88fa vkládání zápatí, jmenné prostory, saxon
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   270
		<p>
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   271
			Just a passthrough command, so these pipelines should produce the same hash:
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   272
		</p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   273
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   274
		<m:pre jazyk="bash"><![CDATA[
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   275
relpipe-in-fstab | relpipe-tr-validator | sha512sum
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   276
relpipe-in-fstab | sha512sum]]></m:pre>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   277
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   278
		<p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   279
			This tool can be used for testing whether a file contains valid relational data:
87
25dec6931f18 Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents: 23
diff changeset
   280
		</p>
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   281
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   282
		<m:pre jazyk="bash"><![CDATA[
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   283
if relpipe-tr-validator < "some-file.rp" &> /dev/null; then
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   284
	echo "valid relational data";
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   285
else
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   286
	echo "garbage";
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   287
fi]]></m:pre>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   288
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   289
		<p>or as a one-liner:</p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   290
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   291
		<m:pre jazyk="bash"><![CDATA[relpipe-tr-validator < "some-file.rp" &> /dev/null && echo "ok" || echo "error"]]></m:pre>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   292
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   293
		<p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   294
			If an error is found, it is reported on STDERR. So just omit the <code>&amp;</code> in order to see the error message.
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   295
		</p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   296
		
180
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   297
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   298
		<h3>/etc/fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl</h3>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   299
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   300
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   301
			As we have seen before, we can convert <code>/etc/fstab</code> (or <code>mtab</code>)
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   302
			to e.g. an XML or a nice and colorful table using <m:name/>.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   303
			But we can also convert these data back to the <code>fstab</code> format. And do it with proper indentation/padding.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   304
			Fstab has a simple format where values are separated by one or more whitespace characters.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   305
			But without proper indentation, these files look a bit obfuscated and hard to read (however, they are valid).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   306
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   307
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   308
		<m:pre jazyk="text" src="examples/relpipe-out-fstab.txt"/>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   309
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   310
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   311
			So let's build a pipeline that reformats the <code>fstab</code> and makes it more readable.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   312
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   313
			
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   314
		<m:pre jazyk="bash">relpipe-in-fstab | relpipe-out-fstab &gt; reformatted-fstab.txt</m:pre>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   315
			
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   316
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   317
			We can hack together a script called <code>relpipe-out-fstab</code> that accepts relational data and produces <code>fstab</code> data.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   318
			Later this will be probably implemented as a regular tool, but for now, it is just an example of a ad-hoc shell script:
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   319
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   320
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   321
		<m:pre jazyk="bash" src="examples/relpipe-out-fstab.sh" odkaz="ano"/>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   322
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   323
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   324
			In the first part, we prepend a single record (<code>relpipe-in-cli</code>) before the data coming from STDIN (<code>cat</code>).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   325
			Then, we use <code>relpipe-out-nullbyte</code> to convert relational data to values separated by a null-byte.
184
9ad44348e6aa small fixes
František Kučera <franta-hg@frantovo.cz>
parents: 180
diff changeset
   326
			This command processes only attribute values (skips relation and attribute names).
180
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   327
			Then we used <code>xargs</code> to read the null-separated values and execute a Perl command for each record (pass to it a same number of arguments, as we have attributes: <code>--max-args=7</code>).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   328
			Perl does the actual formatting: adds padding and does some little tunning (merges two attributes and replaces empty values with <em>none</em>).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   329
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   330
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   331
		<p>This is formatted version of the <code>fstab</code> above:</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   332
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   333
		<m:pre jazyk="text" src="examples/relpipe-out-fstab.formatted.txt"/>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   334
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   335
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   336
			And using following command we can verify, that the files differ only in comments and whitespace:
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   337
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   338
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   339
		<pre>relpipe-in-fstab | relpipe-out-fstab | diff -w /etc/fstab -</pre>
195
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   340
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   341
		<p>
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   342
			Another check (should print same hashes):
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   343
		</p>
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   344
		
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   345
		<pre><![CDATA[relpipe-in-fstab | sha512sum 
65138c5d5a7c examples: fstab - another check
František Kučera <franta-hg@frantovo.cz>
parents: 187
diff changeset
   346
relpipe-in-fstab | relpipe-out-fstab | relpipe-in-fstab | sha512sum]]></pre>
180
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   347
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   348
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   349
			Regular implementation of <code>relpipe-out-fstab</code> will probably keep the comments
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   350
			(it needs also one more attribute and small change in <code>relpipe-in-fstab</code>).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   351
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   352
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   353
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   354
			For just mere <code>fstab</code> reformatting, this approach is a bit overengineering.
184
9ad44348e6aa small fixes
František Kučera <franta-hg@frantovo.cz>
parents: 180
diff changeset
   355
			We could skip the whole relational thing and do just something like this:
180
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   356
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   357
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   358
		<m:pre jazyk="bash">cat /etc/fstab | grep -v '^#' | sed -E 's/\s+/\n/g' | tr \\n \\0 | xargs -0 -n7 ...</m:pre>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   359
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   360
		<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   361
			plus prepend the comment (or do everything in Perl).
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   362
			But this example is intended as a demostration, how we can
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   363
			1) prepend some additional data before the data from STDIN
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   364
			2) use <m:name/> and traditional tools like <code>xargs</code> or <code>perl</code> together.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   365
			And BTW we have implemented a (simple but working) <em>relpipe output filter</em> – and did it without any serious programming, just put some existing commands together :-)
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   366
		</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   367
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   368
		<blockquote>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   369
			<p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   370
				There is more Unix-nature in one line of shell script than there is in ten thousand lines of C.
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   371
				<m:podČarou>see <a href="http://www.catb.org/~esr/writings/unix-koans/ten-thousand.html">Master Foo and the Ten Thousand Lines</a></m:podČarou>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   372
			</p>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   373
		</blockquote>
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   374
		
207
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   375
		<h2>Rename VG in /etc/fstab using relpipe-tr-sed</h2>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   376
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   377
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   378
			Let's expect that we have a <code>/etc/fstab</code> with many lines defining the mount-points (directories) of particular devices (disks) and we are using LVM.
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   379
			If we rename a volume group (VG), we have to change all of them. The lines look like this one:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   380
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   381
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   382
		<pre>/dev/alpha/photos    /mnt/photos/    btrfs    noauto,noatime,nodiratime    0  0</pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   383
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   384
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   385
			We want to change all lines from <code>alpha</code> to <code>beta</code> (the new VG name).
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   386
			This can be done by:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   387
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   388
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   389
		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   390
	| relpipe-tr-sed 'fstab' 'device' '^/dev/alpha/' '/dev/beta/' \
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   391
	| relpipe-out-fstab]]></m:pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   392
	
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   393
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   394
			Unlike the text-oriented <code>sed</code> command, the relational <code>relpipe-tr-sed</code> works only with given relation (<code>fstab</code>) and given attribute (<code>device</code>)
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   395
			and it would leave untouched other relations and attributes in the stream.
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   396
			So it would not replace the strings on unwanted places (if there are any random matches).
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   397
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   398
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   399
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   400
			Even the relation names and attribute names are specified as a regular expression, so we can (purposefully) modify multiple relations or attributes.
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   401
			For example we can put zeroes in both <code>dump</code> and <code>pass</code> attributes:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   402
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   403
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   404
		<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-tr-sed 'fstab' 'dump|pass' '.*' '0' | relpipe-out-fstab]]></m:pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   405
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   406
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   407
			n.b. the data types must be respected, we can not e.g. put <code>abc</code> in the <code>pass</code> attribute because it is declared as <code>integer</code>.
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   408
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   409
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   410
		<h2>Using relpipe-tr-sed with groups and backreferences</h2>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   411
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   412
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   413
			This tool also support regex groups and backreferences. Thus we can use parts of the matched string in our replacement string:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   414
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   415
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   416
		<m:pre jazyk="bash"><![CDATA[relpipe-in-cli generate r 1 a string "some string xxx_123 some zzz_456 other" \
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   417
	| relpipe-tr-sed 'r' 'a' '([a-z]{3})_([0-9]+)' '$2:$1' \
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   418
	| relpipe-out-tabular]]></m:pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   419
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   420
		<p>Which would convert this:</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   421
		<pre><![CDATA[r:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   422
 ╭────────────────────────────────────────╮
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   423
 │ a                             (string) │
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   424
 ├────────────────────────────────────────┤
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   425
 │ some string xxx_123 some zzz_456 other │
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   426
 ╰────────────────────────────────────────╯
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   427
Record count: 1]]></pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   428
		
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   429
		<p>into this:</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   430
		<pre><![CDATA[r:
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   431
 ╭────────────────────────────────────────╮
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   432
 │ a                             (string) │
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   433
 ├────────────────────────────────────────┤
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   434
 │ some string 123:xxx some 456:zzz other │
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   435
 ╰────────────────────────────────────────╯
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   436
Record count: 1]]></pre>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   437
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   438
		<p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   439
			If there were any other relations or attributes in the stream, they would be unaffected by this transformation,
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   440
			becase we specified <code>'r' 'a'</code> instead of some wider regular expression that would match more relations or attributes.
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   441
		</p>
4e45b9a177c2 examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents: 198
diff changeset
   442
		
87
25dec6931f18 Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents: 23
diff changeset
   443
	</text>
4
1bb39595a51c genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   444
1
a05c6f3cbc3e základ, první verze
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   445
</stránka>