NAME
prefix - prefixes hostname time information or more to lines from stdin (or read from files)
SYNOPSIS
% 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:
host.example.com 2013-10-13 16:51:26 OK: System operational
host.example.com 2013-10-13 16:55:47 Warning: Disk bandwidth saturated
host.example.com 2013-10-13 16:55:49 Warning: Things are wonky: disks spinning backwards
host.example.com 2013-10-13 16:55:50 Error: Data read wackbards
host.example.com 2013-10-13 16:56:10 OK: Spacetime reversal complete
Note that the hostname (host.example.com) and the date have been prepended to the lines from the file
DESCRIPTION
A text filter that prepends (or appends) data to lines read from stdin or named files, and echos them to stdout
OPTIONS
--text='arbitrary text here'
add any particular string you like. For example
% ./some_program | prefix -text="TestRun17:" -utime > logfile.txt
The above example would prefix each line output from some_program with the time and the text 'TestRun17:' (without the quotes).
--timestamp
Add a timestamp to each line
--utimestamp
Add a timestamp, showing fractions of a second to each line
Example:
% ls -l | prefix -timestamp
--hoststamp
Add the hostname to each line
--no-space
Don't put a space between the original line read and the data added to each line
--suffix
Show added data at end of line, not start of line
For example:
% echo "abc" | prefix -suffix -text=:Run17:
will output
abc "Run17:
whereas:
% echo "abc" | prefix -text=:Run17:
would output
:Run17: abc
--elapsed
Show time elapsed since last line seen. Shows fractional time.
--quote
Show each original line read in single quotes
AUTHOR
Josh Rabinowitz <joshr>