NAME
prefix - adds 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
The prefix program also supports adding arbitrary text, current time to the microsecond, time elapsed since invocation, time since last line output, adding text at the end instead of the beginning of the line, and more.
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
% ls -l | prefix -timestamp
--utimestamp
Add a timestamp, showing fractions of a second to each line
Example:
% ls -l | prefix -utimestamp
--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 all added data at end of line, not start of line
For example:
% echo "abc" | prefix -suffix -text=:Run17:
will output
abc :Run17:
(note how the added text is now at the end of the line) whereas:
% echo "abc" | prefix -text=:Run17:
would output
:Run17: abc
--elapsedstamp
Add the time since the prefix program was started to each line
--diffstamp
Add time elapsed since last line seen. Shows fractional time.
This can be useful when tailing logfiles or output of programs and you want to see which lines take longer or shorter to output.
--raw
Show --elapsedstamp and --diffstamp times in seconds, and never in other units (like minutes or microseconds, for example)
--quote
Show each original line read in single quotes
AUTHOR
Josh Rabinowitz <joshr>