summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-21 05:13:49 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-25 01:21:58 +0000
commit5595024a2fdd726d88d57c5a06b633b752ef31db (patch)
tree19655a84f99d555257653e25ff4c5a1f71a94f44 /doc
parenteea6b49210edf69682b2d0606bee17bbccb3765b (diff)
downloadcoreutils-5595024a2fdd726d88d57c5a06b633b752ef31db.tar.xz
doc: provide an example for prefixing all tail output lines
* doc/coreutils.texi (tail invocation): Provide an example using awk to convert tail ==> file <== headers to file: prefixes on each line. Suggested by Stephen Shirley.
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi14
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 7918aec6a..88e16503d 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -2839,14 +2839,22 @@ tail [@var{option}]@dots{} [@var{file}]@dots{}
@end example
If more than one @var{file} is specified, @command{tail} prints a
-one-line header consisting of:
+one-line header before the output for each @var{file}, consisting of:
@example
==> @var{file name} <==
@end example
-@noindent
-before the output for each @var{file}.
+For further processing of tail output, it can be useful to convert the
+file headers to line prefixes, which can be done like:
+
+@example
+tail @dots{} |
+awk '
+ /^==> .* <==$/ @{prefix=substr($0,5,length-8)":"; next@}
+ @{print prefix$0@}
+' | @dots{}
+@end example
@cindex BSD @command{tail}
GNU @command{tail} can output any amount of data (some other versions of