equal
deleted
inserted
replaced
65 <m:pre jazyk="bash" src="examples/relpipe-out-fstab.sh" odkaz="ano"/> |
65 <m:pre jazyk="bash" src="examples/relpipe-out-fstab.sh" odkaz="ano"/> |
66 |
66 |
67 <p> |
67 <p> |
68 In the first part, we prepend a single record (<code>relpipe-in-cli</code>) before the data coming from STDIN (<code>cat</code>). |
68 In the first part, we prepend a single record (<code>relpipe-in-cli</code>) before the data coming from STDIN (<code>cat</code>). |
69 Then, we use <code>relpipe-out-nullbyte</code> to convert relational data to values separated by a null-byte. |
69 Then, we use <code>relpipe-out-nullbyte</code> to convert relational data to values separated by a null-byte. |
70 This command processes only attribute values (relation and attribute names are skipped). |
70 This command processes only attribute values (skips relation and attribute names). |
71 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>). |
71 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>). |
72 Perl does the actual formatting: adds padding and does some little tunning (merges two attributes and replaces empty values with <em>none</em>). |
72 Perl does the actual formatting: adds padding and does some little tunning (merges two attributes and replaces empty values with <em>none</em>). |
73 </p> |
73 </p> |
74 |
74 |
75 <p>This is formatted version of the <code>fstab</code> above:</p> |
75 <p>This is formatted version of the <code>fstab</code> above:</p> |
87 (it needs also one more attribute and small change in <code>relpipe-in-fstab</code>). |
87 (it needs also one more attribute and small change in <code>relpipe-in-fstab</code>). |
88 </p> |
88 </p> |
89 |
89 |
90 <p> |
90 <p> |
91 For just mere <code>fstab</code> reformatting, this approach is a bit overengineering. |
91 For just mere <code>fstab</code> reformatting, this approach is a bit overengineering. |
92 Wo could skip the whole relational thing and do just something like this: |
92 We could skip the whole relational thing and do just something like this: |
93 </p> |
93 </p> |
94 |
94 |
95 <m:pre jazyk="bash">cat /etc/fstab | grep -v '^#' | sed -E 's/\s+/\n/g' | tr \\n \\0 | xargs -0 -n7 ...</m:pre> |
95 <m:pre jazyk="bash">cat /etc/fstab | grep -v '^#' | sed -E 's/\s+/\n/g' | tr \\n \\0 | xargs -0 -n7 ...</m:pre> |
96 |
96 |
97 <p> |
97 <p> |