prefix - prefixes hostname time information or more to lines from stdin (or read from files)
% tail -f /var/log/some.log | prefix -host -timestamp
tails a file, showing each line with a hostname and a timestamp like. So if we were tailing a growing file with lines like:
OK: System operational Warning: Disk bandwidth saturated
we would get real-time output like:
arachnid.example.com 2013-10-13 16:55:49 Warning: Things are wonky: disks spinning backwards arachnid.example.com 2013-10-13 16:55:50 Error: Data read wackbards arachnid.example.com 2013-10-13 16:56:10 OK: Spacetime reversal complete
Note that the hostname (arachnid.example.com) and the date have been prepended.
See options below for more details.
A text filter that prepends (or appends) data to lines read from stdin or named files, and echos them to stdout
add any particular string you like.
Add a timestamp
Add a timestamp, showing fractions of a second
Add the hostname
Don't put a space between the original line read and the data added
Show added data at end of line, not start of line
Show time elapsed since last line seen
Show each original line read in single quotes
Josh Rabinowitz <joshr>
To install prefix, copy and paste the appropriate command in to your terminal.
cpanm
cpanm prefix
CPAN shell
perl -MCPAN -e shell install prefix
For more information on module installation, please visit the detailed CPAN module installation guide.