On 24/11/15 01:22, Pádraig Brady wrote:
> On 22/11/15 20:16, Bob Proulx wrote:
>> Pádraig Brady wrote:
>>> Upon more careful consideration, I'm 50:50
>>> about adding per line processing to tail.
>>> ...
>>> Perhaps we could just add the above snippet to the docs?
>>> The big advantage is that it works everywhere already.
>>
>> Perhaps simply add a reference to 'multitail' being available?  It is
>> still my preferred tool for that type of thing.
> 
> I could only see how to prefix with the window id in multitail,
> and anyway it would be better to reference more standard tools if possible.
> 
> Proposed doc patch is attached.

correct patch this time :/

cheers,
Pádraig

>From f267fca48c2cffd0783b31c6ca82a7af56dcb327 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Sat, 21 Nov 2015 05:13:49 +0000
Subject: [PATCH] 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.
---
 doc/coreutils.texi | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 8034807..4e8479d 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
-- 
2.5.0

Reply via email to