1 |
commit: c2e9f75dbf89db8e19615dc0b15b05f4d5698584 |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jan 8 09:24:41 2020 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 9 08:31:55 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=c2e9f75d |
7 |
|
8 |
tools-reference/head-and-tail: Add another example for tail. |
9 |
|
10 |
The bad example is taken from the script referenced in bug 536654. |
11 |
|
12 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
13 |
|
14 |
tools-reference/head-and-tail/text.xml | 8 ++++++++ |
15 |
1 file changed, 8 insertions(+) |
16 |
|
17 |
diff --git a/tools-reference/head-and-tail/text.xml b/tools-reference/head-and-tail/text.xml |
18 |
index e2b7553..06f17de 100644 |
19 |
--- a/tools-reference/head-and-tail/text.xml |
20 |
+++ b/tools-reference/head-and-tail/text.xml |
21 |
@@ -36,6 +36,14 @@ To specify "the last five lines", use <c>tail -n5</c>. To specify "all |
22 |
but the first five lines", use <c>tail -n+6</c>. |
23 |
</p> |
24 |
|
25 |
+<codesample lang="ebuild"> |
26 |
+# bad: drop first five lines, clumsily computing line count |
27 |
+tail -n $(($(wc -l in.txt | awk '{print $1}') - 5)) in.txt > out.txt |
28 |
+ |
29 |
+# good: let tail count lines from the beginning of the file |
30 |
+tail -n +6 in.txt > out.txt |
31 |
+</codesample> |
32 |
+ |
33 |
<warning> |
34 |
<c>head/tail -5</c> syntax is deprecated and not POSIX compliant. |
35 |
</warning> |