relpipe-data/examples.xml
author František Kučera <franta-hg@frantovo.cz>
Thu, 06 Dec 2018 21:16:49 +0100
branchv_0
changeset 189 47907749817f
parent 187 c952261978e8
child 195 65138c5d5a7c
permissions -rw-r--r--
screenshots: Haiku
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
		
185
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    12
		<h3>relpipe-in-cli: Hello Wordl!</h3>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    13
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    14
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    15
			Let's start with and obligatory Hello World example.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    16
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    17
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    18
		<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
    19
	"a" "integer" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    20
	"b" "string" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    21
	"c" "boolean" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    22
	"1" "Hello" "true" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    23
	"2" "World!" "false"]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    24
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    25
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    26
			This command generates relational data.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    27
			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
    28
			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
    29
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    30
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    31
		<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
    32
		"a" "integer" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    33
		"b" "string" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    34
		"c" "boolean" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    35
		"1" "Hello" "true" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    36
		"2" "World!" "false" \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    37
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    38
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    39
		<p>Output:</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    40
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    41
		<pre><![CDATA[relation_from_cli:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    42
 ╭─────────────┬────────────┬─────────────╮
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    43
 │ a (integer) │ b (string) │ c (boolean) │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    44
 ├─────────────┼────────────┼─────────────┤
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    45
 │           1 │ Hello      │        true │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    46
 │           2 │ World!     │       false │
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
Record count: 2
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    49
]]></pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    50
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    51
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    52
			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
    53
			and then their definitions (names and types),
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    54
			followed by the data.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    55
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    56
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    57
		<h3>relpipe-in-cli: STDIN</h3>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    58
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    59
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    60
			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
    61
			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
    62
			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
    63
			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
    64
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    65
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    66
		<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
    67
	| tr \\n \\0 \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    68
	| 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
    69
		a integer \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    70
		b string \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    71
		c boolean \
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    72
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    73
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    74
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    75
			The output is same as above.
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    76
			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
    77
			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
    78
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    79
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    80
		<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
    81
	| 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
    82
	| relpipe-out-tabular
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    83
]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    84
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    85
		<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
    86
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    87
		<pre><![CDATA[mc_args:
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
 │ a (string) │
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
 │ mc         │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    92
 │ /etc/      │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    93
 │ /tmp/      │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    94
 ╰────────────╯
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    95
Record count: 3]]></pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    96
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    97
		<p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
    98
			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
    99
		</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   100
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   101
		<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
   102
	| 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
   103
	| relpipe-out-tabular]]></m:pre>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   104
	
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   105
		<p>Will display something like this:</p>
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   106
		
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   107
		<pre><![CDATA[files:
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   108
 ╭───────────────────────────────────╮
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   109
 │ file_name                (string) │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   110
 ├───────────────────────────────────┤
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   111
 │ /etc/ssh/ssh_host_ecdsa_key       │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   112
 │ /etc/ssh/sshd_config              │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   113
 │ /etc/ssh/ssh_host_ed25519_key.pub │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   114
 │ /etc/ssh/ssh_host_ecdsa_key.pub   │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   115
 │ /etc/ssh/ssh_host_rsa_key         │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   116
 │ /etc/ssh/ssh_config               │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   117
 │ /etc/ssh/ssh_host_ed25519_key     │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   118
 │ /etc/ssh/ssh_import_id            │
6cd2e54d90ea examples: relpipe-in-cli
František Kučera <franta-hg@frantovo.cz>
parents: 184
diff changeset
   119
 │ /etc/ssh/ssh_host_rsa_key.pub     │
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
Record count: 9]]></pre>
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
		
186
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   124
		<h3>relpipe-in-fstab</h3>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   125
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   126
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   127
			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
   128
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   129
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   130
		<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
   131
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   132
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   133
			and see them as a nice table:
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   134
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   135
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   136
		<pre><![CDATA[fstab:
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   137
 ╭─────────────────┬──────────────────────────────────────┬──────────────────────┬───────────────┬───────────────────────────────────────┬────────────────┬────────────────╮
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   138
 │ 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
   139
 ├─────────────────┼──────────────────────────────────────┼──────────────────────┼───────────────┼───────────────────────────────────────┼────────────────┼────────────────┤
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   140
 │ 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
   141
 │                 │ /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
   142
 │                 │ /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
   143
 │ 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
   144
 │                 │ /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
   145
 ╰─────────────────┴──────────────────────────────────────┴──────────────────────┴───────────────┴───────────────────────────────────────┴────────────────┴────────────────╯
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   146
Record count: 5]]></pre>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   147
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   148
		<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
   149
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   150
		<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
   151
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   152
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   153
			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
   154
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   155
		
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   156
		<p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   157
			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
   158
		</p>
e33f13c91289 examples: relpipe-in-fstab
František Kučera <franta-hg@frantovo.cz>
parents: 185
diff changeset
   159
		
187
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   160
		<h3>relpipe-out-xml</h3>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   161
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   162
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   163
			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
   164
			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
   165
			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
   166
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   167
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   168
		<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
   169
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   170
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   171
			Will produce XML like this:
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   172
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   173
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   174
		<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
   175
<pipe>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   176
	<relation>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   177
		<name>fstab</name>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   178
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   179
			<attribute>UUID</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   180
			<attribute>29758270-fd25-4a6c-a7bb-9a18302816af</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   181
			<attribute>/</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   182
			<attribute>ext4</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   183
			<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
   184
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   185
			<attribute>1</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   186
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   187
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   188
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   189
			<attribute>/dev/sr0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   190
			<attribute>/media/cdrom0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   191
			<attribute>udf,iso9660</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   192
			<attribute>user,noauto</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   193
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   194
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   195
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   196
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   197
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   198
			<attribute>/dev/sde</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   199
			<attribute>/mnt/data</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   200
			<attribute>ext4</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   201
			<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
   202
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   203
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   204
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   205
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   206
			<attribute>UUID</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   207
			<attribute>a2b5f230-a795-4f6f-a39b-9b57686c86d5</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   208
			<attribute>/home</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   209
			<attribute>btrfs</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   210
			<attribute>relatime</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   211
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   212
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   213
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   214
		<record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   215
			<attribute></attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   216
			<attribute>/dev/mapper/sdf_crypt</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   217
			<attribute>/mnt/private</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   218
			<attribute>xfs</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   219
			<attribute>relatime</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   220
			<attribute>0</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   221
			<attribute>2</attribute>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   222
		</record>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   223
	</relation>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   224
</pipe>]]></m:pre>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   225
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   226
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   227
			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
   228
			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
   229
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   230
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   231
		<p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   232
			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
   233
		</p>
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   234
		
c952261978e8 examples: relpipe-out-xml
František Kučera <franta-hg@frantovo.cz>
parents: 186
diff changeset
   235
		
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   236
		<h3>relpipe-tr-validator</h3>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   237
		
2
ab9099ff88fa vkládání zápatí, jmenné prostory, saxon
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
   238
		<p>
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   239
			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
   240
		</p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   241
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   242
		<m:pre jazyk="bash"><![CDATA[
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   243
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
   244
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
   245
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   246
		<p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   247
			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
   248
		</p>
176
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   249
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   250
		<m:pre jazyk="bash"><![CDATA[
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   251
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
   252
	echo "valid relational data";
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   253
else
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   254
	echo "garbage";
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   255
fi]]></m:pre>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   256
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   257
		<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
   258
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   259
		<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
   260
		
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   261
		<p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   262
			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
   263
		</p>
46042297e0d6 relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents: 140
diff changeset
   264
		
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
   265
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   266
		<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
   267
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   268
		<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
   269
			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
   270
			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
   271
			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
   272
			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
   273
			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
   274
		</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
   275
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   276
		<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
   277
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   278
		<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
   279
			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
   280
		</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
   281
			
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   282
		<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
   283
			
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   284
		<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
   285
			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
   286
			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
   287
		</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
   288
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   289
		<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
   290
		
d342de2e09a4 examples: fstab formatting using -in-fstab, -out-nullbyte, xargs and Perl
František Kučera <franta-hg@frantovo.cz>
parents: 176
diff changeset
   291
		<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
   292
			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
   293
			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
   294
			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
   295
			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
   296
			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
   297
		</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
   298
		
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
		<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
   300
		
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
		<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
   302
		
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
		<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
   304
			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
   305
		</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
   306
		
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
		<pre>relpipe-in-fstab | relpipe-out-fstab | diff -w /etc/fstab -</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
   308
		
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
		<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
   310
			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
   311
			(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
   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
		<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
   315
			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
   316
			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
   317
		</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
   318
		
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
		<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
   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
		<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
   322
			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
   323
			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
   324
			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
   325
			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
   326
			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
   327
		</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
   328
		
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
		<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
   330
			<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
   331
				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
   332
				<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
   333
			</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
   334
		</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
   335
		
87
25dec6931f18 Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents: 23
diff changeset
   336
	</text>
4
1bb39595a51c genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
   337
1
a05c6f3cbc3e základ, první verze
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   338
</stránka>