From c2e9f75dbf89db8e19615dc0b15b05f4d5698584 Mon Sep 17 00:00:00 2001 From: Ulrich Müller Date: Wed, 8 Jan 2020 10:24:41 +0100 Subject: tools-reference/head-and-tail: Add another example for tail. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bad example is taken from the script referenced in bug 536654. Signed-off-by: Ulrich Müller --- tools-reference/head-and-tail/text.xml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools-reference/head-and-tail') 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 tail -n5. To specify "all but the first five lines", use tail -n+6.

+ +# bad: drop first five lines, clumsily computing line count +tail -n $(($(wc -l in.txt | awk '{print $1}') - 5)) in.txt > out.txt + +# good: let tail count lines from the beginning of the file +tail -n +6 in.txt > out.txt + + head/tail -5 syntax is deprecated and not POSIX compliant. -- cgit v1.2.3-65-gdbad