commit:     c2e9f75dbf89db8e19615dc0b15b05f4d5698584
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  8 09:24:41 2020 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Jan  9 08:31:55 2020 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=c2e9f75d

tools-reference/head-and-tail: Add another example for tail.

The bad example is taken from the script referenced in bug 536654.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 tools-reference/head-and-tail/text.xml | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools-reference/head-and-tail/text.xml 
b/tools-reference/head-and-tail/text.xml
index e2b7553..06f17de 100644
--- a/tools-reference/head-and-tail/text.xml
+++ b/tools-reference/head-and-tail/text.xml
@@ -36,6 +36,14 @@ To specify "the last five lines", use <c>tail -n5</c>. To 
specify "all
 but the first five lines", use <c>tail -n+6</c>.
 </p>
 
+<codesample lang="ebuild">
+# bad: drop first five lines, clumsily computing line count
+tail -n $(($(wc -l in.txt | awk '{print $1}') - 5)) in.txt &gt; out.txt
+
+# good: let tail count lines from the beginning of the file
+tail -n +6 in.txt &gt; out.txt
+</codesample>
+
 <warning>
 <c>head/tail -5</c> syntax is deprecated and not POSIX compliant.
 </warning>

Reply via email to