Skip to content

Commit dbf63ac

Browse files
corrected typos and improved descriptions
1 parent a1176c1 commit dbf63ac

File tree

13 files changed

+19
-23
lines changed

13 files changed

+19
-23
lines changed

cat-tac.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
Have a nice day
9898
apple banana cherry
9999

100-
# here's an example with no newline character at the end of first input
100+
# here's an example without newline character at the end of first input
101101
$ printf 'Some\nNumbers' | cat - nums.txt
102102
Some
103103
Numbers3.14

comm.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
,,3
7474
,4
7575
,5
76-
</code></pre><blockquote><p><img src=./images/info.svg alt=info> Note that the collating order used for <code>comm</code> should be same as the one used to <code>sort</code> the input files.</blockquote><blockquote><p><img src=./images/info.svg alt=info> You can use the <code>--nocheck-order</code> option to apply <code>comm</code> for unsorted inputs. However, as per the documentation, this option "is not guaranteed to produce any particular output."</blockquote><h2 id=suppressing-columns><a class=header href=#suppressing-columns>Suppressing columns</a></h2><p>You can use one or more of the following options to suppress columns:<ul><li><code>-1</code> to suppress lines unique to the first file<li><code>-2</code> to suppress lines unique to the second file<li><code>-3</code> to suppress lines common to both the files</ul><p>Here's how the output looks like when you suppress one of the columns:<pre><code class=language-bash># suppress lines common to both the files
76+
</code></pre><blockquote><p><img src=./images/info.svg alt=info> Collating order for <code>comm</code> should be same as the one used to <code>sort</code> the input files.</blockquote><blockquote><p><img src=./images/info.svg alt=info> <code>--nocheck-order</code> option can be used for unsorted inputs. However, as per the documentation, this option "is not guaranteed to produce any particular output."</blockquote><h2 id=suppressing-columns><a class=header href=#suppressing-columns>Suppressing columns</a></h2><p>You can use one or more of the following options to suppress columns:<ul><li><code>-1</code> to suppress lines unique to the first file<li><code>-2</code> to suppress lines unique to the second file<li><code>-3</code> to suppress lines common to both the files</ul><p>Here's how the output looks like when you suppress one of the columns:<pre><code class=language-bash># suppress lines common to both the files
7777
$ comm -3 colors_1.txt colors_2.txt
7878
Black
7979
Brown

csplit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
tea
8787
</code></pre><blockquote><p><img src=./images/warning.svg alt=warning> You'll get an error if the given regexp isn't found in the input.</blockquote><pre><code class=language-bash>$ csplit -q purchases.txt '/xyz/'
8888
csplit: ‘/xyz/’: match not found
89-
</code></pre><blockquote><p><img src=./images/info.svg alt=info> See <a href=https://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html>Regular Expressions</a> chapter from my <strong>GNU grep</strong> ebook if you want to learn about regexp syntax and features.</blockquote><h2 id=regexp-offset><a class=header href=#regexp-offset>Regexp offset</a></h2><p>You can also provide offset numbers that'll affect where the matching line and its surrounding lines should be placed. When the offset is greater than zero, the split will happen that many lines after the matching line. The default offset is zero.<pre><code class=language-bash># matching line will be part of the first file
89+
</code></pre><blockquote><p><img src=./images/info.svg alt=info> See <a href=https://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html>Regular Expressions</a> chapter from my <strong>GNU grep</strong> ebook if you want to learn about regexp syntax and features.</blockquote><h2 id=regexp-offset><a class=header href=#regexp-offset>Regexp offset</a></h2><p>You can also provide offset numbers that'll affect where the matching line and its surrounding lines should be placed. When the offset is greater than zero, the split will happen that many lines after the matching line. The default offset is zero.<pre><code class=language-bash># when the offset is '1', matching line will be part of the first file
9090
$ csplit -q purchases.txt '/t.*p/1'
9191
$ head xx*
9292
==> xx00 <==
@@ -183,7 +183,7 @@
183183

184184
$ csplit -q purchases.txt '/tea/' '{4}'
185185
csplit: ‘/tea/’: match not found on repetition 3
186-
</code></pre><h2 id=keep-files-on-error><a class=header href=#keep-files-on-error>Keep files on error</a></h2><p>By default, <code>csplit</code> will remove the created output files if there's an error or a signal that causes the command to stop. You can use the <code>-k</code> option to keep such files. One use case is line number based splitting with <code>{*}</code> modifier.<pre><code class=language-bash>$ seq 10 | csplit -q - 4 '{*}'
186+
</code></pre><h2 id=keep-files-on-error><a class=header href=#keep-files-on-error>Keep files on error</a></h2><p>By default, <code>csplit</code> will remove the created output files if there's an error or a signal that causes the command to stop. You can use the <code>-k</code> option to keep such files. One use case is line number based splitting with the <code>{*}</code> modifier.<pre><code class=language-bash>$ seq 10 | csplit -q - 4 '{*}'
187187
csplit: ‘4’: line number out of range on repetition 2
188188
$ ls xx*
189189
ls: cannot access 'xx*': No such file or directory

join.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
fig 100
8484
pen 2
8585
tshirt 3
86-
</code></pre><h2 id=change-field-separator><a class=header href=#change-field-separator>Change field separator</a></h2><p>You can use the <code>-t</code> option to specify a single byte character as the field separator. Use <code>\0</code> to specify NUL as the separator. Empty string will cause entire input line content to be considered as keys. Depending on your shell you can use <a href=https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>ANSI-C quoting</a> to use escapes like <code>\t</code> instead of a literal tab character.<p>The output field separator will be same as the value used for the <code>-t</code> option. Here's an example:<pre><code class=language-bash>$ cat marks.csv
86+
</code></pre><h2 id=change-field-separator><a class=header href=#change-field-separator>Change field separator</a></h2><p>You can use the <code>-t</code> option to specify a single byte character as the field separator. The output field separator will be same as the value used for the <code>-t</code> option. Use <code>\0</code> to specify NUL as the separator. Empty string will cause entire input line content to be considered as keys. Depending on your shell you can use <a href=https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html>ANSI-C quoting</a> to use escapes like <code>\t</code> instead of a literal tab character.<pre><code class=language-bash>$ cat marks.csv
8787
ECE,Raj,53
8888
ECE,Joel,72
8989
EEE,Moi,68
@@ -147,7 +147,7 @@
147147
Name,Chemistry,Maths,Physics
148148
Amy,85,78,95
149149
Raj,72,67,76
150-
</code></pre><h2 id=same-number-of-output-fields><a class=header href=#same-number-of-output-fields>Same number of output fields</a></h2><p>If you use <code>auto</code> as the argument for the <code>-o</code> option, first line of both the files will be used to determine the number of output fields. If the other lines have extra fields, they will be discarded.<pre><code class=language-bash>$ join <(printf 'a 1 2\nb p q r') <(printf 'a 3 4\nb x y z')
150+
</code></pre><h2 id=same-number-of-output-fields><a class=header href=#same-number-of-output-fields>Same number of output fields</a></h2><p>If you use <code>auto</code> as the argument for the <code>-o</code> option, first line of both the input files will be used to determine the number of output fields. If the other lines have extra fields, they will be discarded.<pre><code class=language-bash>$ join <(printf 'a 1 2\nb p q r') <(printf 'a 3 4\nb x y z')
151151
a 1 2 3 4
152152
b p q r x y z
153153

nl.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
11) 3.14
9898
13) 42
9999
15) 1000
100-
</code></pre><h2 id=section-wise-numbering><a class=header href=#section-wise-numbering>Section wise numbering</a></h2><p>If you organize your input with special lines conforming to specific patterns, you can control their numbering separately. <code>nl</code> recognizes three types of sections with the following default patterns:<ul><li><code>\:\:\:</code> as header<li><code>\:\:</code> as body<li><code>\:</code> as footer</ul><p>These special lines will be replaced with an empty line after numbering. The numbering will be reset at the start of every section. Here's an example with multiple body sections:<pre><code class=language-bash>$ cat body.txt
100+
</code></pre><h2 id=section-wise-numbering><a class=header href=#section-wise-numbering>Section wise numbering</a></h2><p>If you organize your input with lines conforming to specific patterns, you can control their numbering separately. <code>nl</code> recognizes three types of sections with the following default patterns:<ul><li><code>\:\:\:</code> as header<li><code>\:\:</code> as body<li><code>\:</code> as footer</ul><p>These special lines will be replaced with an empty line after numbering. The numbering will be reset at the start of every section. Here's an example with multiple body sections:<pre><code class=language-bash>$ cat body.txt
101101
\:\:
102102
Hi there
103103
How are you
@@ -170,7 +170,7 @@
170170
3 mango
171171

172172
Footer
173-
</code></pre><p>The <code>-b</code>, <code>-h</code> and <code>-f</code> options control which lines should be numbered for the three types of sections. The various features will discussed later. For now, use <code>a</code> to number all lines of a particular section.<pre><code class=language-bash>$ nl -w1 -s' ' -ha -fa all_sections.txt
173+
</code></pre><p>The <code>-b</code>, <code>-h</code> and <code>-f</code> options control which lines should be numbered for the three types of sections. Use <code>a</code> to number all lines of a particular section (other features will discussed later).<pre><code class=language-bash>$ nl -w1 -s' ' -ha -fa all_sections.txt
174174

175175
1 Header
176176
2 red
@@ -210,7 +210,7 @@
210210
7 mango
211211

212212
8 Footer
213-
</code></pre><p>You can change the two character pattern that is used to identify the different sections using the <code>-d</code> option.<pre><code class=language-bash># pattern changed from \: to %=
213+
</code></pre><p>The <code>-d</code> option allows you to customize the two character pattern used for sections.<pre><code class=language-bash># pattern changed from \: to %=
214214
$ cat body_sep.txt
215215
%=%=
216216
apple

paste.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
Red
4747
Teal
4848
White
49-
5049
$ cat colors_2.txt
5150
Black
5251
Blue
@@ -94,7 +93,6 @@
9493
5,6
9594
7,8
9695
9,10
97-
9896
# five columns
9997
$ seq 10 | paste -d: - - - - -
10098
1:2:3:4:5
@@ -159,7 +157,6 @@
159157
Blue:Brown:Orange:Purple:Red:Teal:White
160158
Black:Blue:Green:Orange:Pink:Red:White
161159

162-
# multiple input files need not have the same number of lines
163160
$ paste -sd, <(seq 3) <(seq 5 9)
164161
1,2,3
165162
5,6,7,8,9

pr.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050

5151

52-
</code></pre><h2 id=columnate><a class=header href=#columnate>Columnate</a></h2><p>The <code>--columns</code> and <code>-a</code> options can be used to merge the input lines in two different ways:<ul><li>merge consecutive lines, similar to the <code>paste</code> command<li>split the input file and then merge them as columns</ul><p>Here's an example to get started. Note that <code>-N</code> is same as using <code>--columns=N</code> where <code>N</code> is the number of columns you want in the output. The default page width is <code>72</code>, which means each column can only have a maximum of <code>72/N</code> characters (including the separator). Tab and space characters will be used to fill the columns as needed. You can use the <code>-J</code> option to prevent <code>pr</code> from truncating longer columns. The <code>-t</code> option is used here to turn off the pagination features.<pre><code class=language-bash># split input into three parts
52+
</code></pre><h2 id=columnate><a class=header href=#columnate>Columnate</a></h2><p>The <code>--columns</code> and <code>-a</code> options can be used to merge the input lines in two different ways:<ul><li>split the input file and then merge them as columns<li>merge consecutive lines, similar to the <code>paste</code> command</ul><p>Here's an example to get started. Note that <code>-N</code> is same as using <code>--columns=N</code> where <code>N</code> is the number of columns you want in the output. The default page width is <code>72</code>, which means each column can only have a maximum of <code>72/N</code> characters (including the separator). Tab and space characters will be used to fill the columns as needed. You can use the <code>-J</code> option to prevent <code>pr</code> from truncating longer columns. The <code>-t</code> option is used here to turn off the pagination features.<pre><code class=language-bash># split input into three parts
5353
# each column width is 72/3 = 24 characters max
5454
$ seq 9 | pr -3t
5555
1 4 7
@@ -102,6 +102,7 @@
102102
$ seq 6 | pr -J -w11 -3ats'::::'
103103
1::::2::::3
104104
4::::5::::6
105+
105106
# you can also use a large number to avoid having to calculate the width
106107
$ seq 6 | pr -J -w500 -3ats'::::'
107108
1::::2::::3

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

searchindex.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

shuf.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
mango
7777
papaya
7878
papaya
79-
</code></pre><blockquote><p><img src=./images/info.svg alt=info> If a limit using <code>-n</code> is not specified, <code>shuf -r</code> will produce output lines indefinitely.</blockquote><h2 id=specify-input-as-arguments><a class=header href=#specify-input-as-arguments>Specify input as arguments</a></h2><p>You can use the <code>-e</code> option to specify multiple input lines as arguments to the command.<pre><code class=language-bash>$ shuf -e hi there 'hello world' good
79+
</code></pre><blockquote><p><img src=./images/info.svg alt=info> If a limit using <code>-n</code> is not specified, <code>shuf -r</code> will produce output lines indefinitely.</blockquote><h2 id=specify-input-as-arguments><a class=header href=#specify-input-as-arguments>Specify input as arguments</a></h2><p>You can use the <code>-e</code> option to specify multiple input lines as arguments to the command.<pre><code class=language-bash># quote the arguments as necessary
80+
$ shuf -e hi there 'hello world' good
8081
hello world
8182
good
8283
hi

0 commit comments

Comments
 (0)