To word wrap the output of a growing log file I tried. . .
$ tail -f log.txt | fold -s
. . . and it works fine on NetBSD and Mac OS X, but on the two Linux distributions I tried (Red Hat and SUSE) I get no output.

As a work around for Linux I can combine tail without -f and watch. . .
$ watch "tail log.txt | fold -s"
. . . but because I'm likely to miss some lines, I threw together a Perl script instead:

#!/usr/bin/perl
use strict;
use warnings;
use File::Tail;
use Text::Wrap;
$Text::Wrap::columns = 72;
my $file = File::Tail->new('/tmp/log.txt');
while ( defined( my $line = $file->read ) ) {
    print wrap( '', '', $line );
}

Despite my workarounds, I'm still left wondering. . .

Can piping tail -f to fold be made to work on Linux the way it works on BSD?

If not, can anyone please explain the difference in the implementation of fold?

Thanks in advance!

Phil


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to