equal
deleted
inserted
replaced
27 and we want to do something (a shell script block) with these directory paths. |
27 and we want to do something (a shell script block) with these directory paths. |
28 </p> |
28 </p> |
29 |
29 |
30 <m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \ |
30 <m:pre jazyk="bash"><![CDATA[relpipe-in-fstab \ |
31 | relpipe-tr-grep --relation 'fstab' --attribute 'type' --value '^btrfs|xfs$' \ |
31 | relpipe-tr-grep --relation 'fstab' --attribute 'type' --value '^btrfs|xfs$' \ |
32 | relpipe-tr-cut 'fstab' 'mount_point' \ |
32 | relpipe-tr-cut --relation 'fstab' --attribute 'mount_point' \ |
33 | relpipe-out-nullbyte \ |
33 | relpipe-out-nullbyte \ |
34 | while read -r -d '' m; do |
34 | while read -r -d '' m; do |
35 echo "$m"; |
35 echo "$m"; |
36 done]]></m:pre> |
36 done]]></m:pre> |
37 |
37 |
86 ╰─────────────┴─────────────╯ |
86 ╰─────────────┴─────────────╯ |
87 Record count: 2]]></pre> |
87 Record count: 2]]></pre> |
88 |
88 |
89 <p>We can put away the <code>a</code> attribute from the <code>numbers</code> relation:</p> |
89 <p>We can put away the <code>a</code> attribute from the <code>numbers</code> relation:</p> |
90 |
90 |
91 <m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|c' | relpipe-out-tabular</m:pre> |
91 <m:pre jazyk="bash">cat both.rp | relpipe-tr-cut --relation 'numbers' --attribute 'b|c' | relpipe-out-tabular</m:pre> |
92 |
92 |
93 <p>and leave the <code>letters</code> relation unaffected:</p> |
93 <p>and leave the <code>letters</code> relation unaffected:</p> |
94 |
94 |
95 <pre><![CDATA[numbers: |
95 <pre><![CDATA[numbers: |
96 ╭─────────────┬─────────────╮ |
96 ╭─────────────┬─────────────╮ |
110 ╰─────────────┴─────────────╯ |
110 ╰─────────────┴─────────────╯ |
111 Record count: 2]]></pre> |
111 Record count: 2]]></pre> |
112 |
112 |
113 <p>Or we can remove <code>a</code> from both relations resp. keep there only attributes whose names match <code>'b|c'</code> regex:</p> |
113 <p>Or we can remove <code>a</code> from both relations resp. keep there only attributes whose names match <code>'b|c'</code> regex:</p> |
114 |
114 |
115 <m:pre jazyk="bash">cat both.rp | relpipe-tr-cut '.*' 'b|c' | relpipe-out-tabular</m:pre> |
115 <m:pre jazyk="bash">cat both.rp | relpipe-tr-cut --relation '.*' --attribute 'b|c' | relpipe-out-tabular</m:pre> |
116 |
116 |
117 <p>Instead of <code>'.*'</code> we could use <code>'numbers|letters'</code> and in this case it will give the same result:</p> |
117 <p>Instead of <code>'.*'</code> we could use <code>'numbers|letters'</code> and in this case it will give the same result:</p> |
118 |
118 |
119 <pre><![CDATA[numbers: |
119 <pre><![CDATA[numbers: |
120 ╭─────────────┬─────────────╮ |
120 ╭─────────────┬─────────────╮ |
134 ╰─────────────╯ |
134 ╰─────────────╯ |
135 Record count: 2]]></pre> |
135 Record count: 2]]></pre> |
136 |
136 |
137 <p>All the time, we are reducing the attributes. But we can also multiply them or change their order:</p> |
137 <p>All the time, we are reducing the attributes. But we can also multiply them or change their order:</p> |
138 |
138 |
139 <m:pre jazyk="bash">cat both.rp | relpipe-tr-cut 'numbers' 'b|a|c' 'b' 'a' 'a' | relpipe-out-tabular</m:pre> |
139 <m:pre jazyk="bash">cat both.rp \ |
|
140 | relpipe-tr-cut --relation 'numbers' --attribute 'b|a|c' --attribute 'b' --attribute 'a' --attribute 'a' \ |
|
141 | relpipe-out-tabular</m:pre> |
140 |
142 |
141 <p> |
143 <p> |
142 n.b. the order in <code>'b|a|c'</code> does not matter and if such regex matches, it preserves the original order of the attributes; |
144 n.b. the order in <code>'b|a|c'</code> does not matter and if such regex matches, it preserves the original order of the attributes; |
143 but if we use multiple regexes to specify attributes, their order and count matters: |
145 but if we use multiple regexes to specify attributes, their order and count matters: |
144 </p> |
146 </p> |
160 │ C │ D │ |
162 │ C │ D │ |
161 ╰─────────────┴─────────────╯ |
163 ╰─────────────┴─────────────╯ |
162 Record count: 2]]></pre> |
164 Record count: 2]]></pre> |
163 |
165 |
164 <p> |
166 <p> |
165 The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut 'numbers'</code> does not affect it in any way. |
167 The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut --relation 'numbers'</code> does not affect it in any way. |
166 </p> |
168 </p> |
167 |
169 |
168 <h2>Process CSV files</h2> |
170 <h2>Process CSV files</h2> |
169 |
171 |
170 <p> |
172 <p> |
193 </p> |
195 </p> |
194 |
196 |
195 <m:pre jazyk="bash"><![CDATA[cat tasks.csv \ |
197 <m:pre jazyk="bash"><![CDATA[cat tasks.csv \ |
196 | relpipe-in-csv \ |
198 | relpipe-in-csv \ |
197 | relpipe-tr-grep --relation 'csv' --attribute 'type' --value 'FIXME' \ |
199 | relpipe-tr-grep --relation 'csv' --attribute 'type' --value 'FIXME' \ |
198 | relpipe-tr-cut 'csv' 'file|description' \ |
200 | relpipe-tr-cut --relation 'csv' --attribute 'file|description' \ |
199 | relpipe-out-tabular]]></m:pre> |
201 | relpipe-out-tabular]]></m:pre> |
200 |
202 |
201 <p>and get result like this:</p> |
203 <p>and get result like this:</p> |
202 |
204 |
203 <pre><![CDATA[csv: |
205 <pre><![CDATA[csv: |