author | František Kučera <franta-hg@frantovo.cz> |
Tue, 05 Feb 2019 19:18:28 +0100 | |
branch | v_0 |
changeset 244 | d4f401b5f90c |
parent 241 | relpipe-data/examples.xml@f71d300205b7 |
child 329 | 5bc2bb8b7946 |
permissions | -rw-r--r-- |
23
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
1 |
<stránka |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
2 |
xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
3 |
xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
0d2729ed16ed
zkouška interního odkazu
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
4 |
|
244
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
5 |
<nadpis>Renaming VG in /etc/fstab using relpipe-tr-sed</nadpis> |
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
6 |
<perex>sed-like substitutions in the relational stream</perex> |
d4f401b5f90c
examples: move each example to a separate page + add generated list of examples
František Kučera <franta-hg@frantovo.cz>
parents:
241
diff
changeset
|
7 |
<m:pořadí-příkladu>00700</m:pořadí-příkladu> |
4
1bb39595a51c
genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
8 |
|
2
ab9099ff88fa
vkládání zápatí, jmenné prostory, saxon
František Kučera <franta-hg@frantovo.cz>
parents:
1
diff
changeset
|
9 |
<text xmlns="http://www.w3.org/1999/xhtml"> |
176
46042297e0d6
relpipe-tr-validator: specification and examples
František Kučera <franta-hg@frantovo.cz>
parents:
140
diff
changeset
|
10 |
|
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
11 |
<p> |
210
f0a2916368e2
small fixes and improvements
František Kučera <franta-hg@frantovo.cz>
parents:
209
diff
changeset
|
12 |
Assume that we have an <code>/etc/fstab</code> with many lines defining the mount-points (directories) of particular devices (disks) and we are using LVM. |
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
13 |
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
|
14 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
15 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
16 |
<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
|
17 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
18 |
<p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
19 |
We want to change all lines from <code>alpha</code> to <code>beta</code> (the new VG name). |
208
91a210d3b66a
examples: relpipe-tr-grep
František Kučera <franta-hg@frantovo.cz>
parents:
207
diff
changeset
|
20 |
This can be done by the power of regular expressions<m:podČarou>see <a href="https://en.wikibooks.org/wiki/Regular_Expressions/Simple_Regular_Expressions">Regular Expressions</a> at Wikibooks</m:podČarou> and this pipeline: |
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
21 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
22 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
23 |
<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
|
24 |
| 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
|
25 |
| relpipe-out-fstab]]></m:pre> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
26 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
27 |
<p> |
209 | 28 |
The <code>relpipe-tr-sed</code> tool works only with given relation (<code>fstab</code>) and given attribute (<code>device</code>) |
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
29 |
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
|
30 |
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
|
31 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
32 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
33 |
<p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
37 |
|
223
6402cd6921c5
examples: small sed fix: .* → .+
František Kučera <franta-hg@frantovo.cz>
parents:
216
diff
changeset
|
38 |
<m:pre jazyk="bash"><![CDATA[relpipe-in-fstab | relpipe-tr-sed 'fstab' 'dump|pass' '.+' '0' | relpipe-out-fstab]]></m:pre> |
207
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
39 |
|
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
40 |
<p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
41 |
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
|
42 |
</p> |
4e45b9a177c2
examples: relpipe-tr-sed
František Kučera <franta-hg@frantovo.cz>
parents:
198
diff
changeset
|
43 |
|
87
25dec6931f18
Lepší odsazení, tabulátory.
František Kučera <franta-hg@frantovo.cz>
parents:
23
diff
changeset
|
44 |
</text> |
4
1bb39595a51c
genrování hlavní nabídky #1
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
45 |
|
1 | 46 |
</stránka> |