Pipe tail output into column

Viewed 314

I'm trying to tail a log file and format the output into columns. This gives me what I want without tail:

cat /var/log/test.log | column -t -s "|"

How can I pipe the output of tail -f var/log/test.log into column?

EDIT: Here's an excerpt from the file. I'm manually adding the first line of the file so it could be used as the column headers, but I could format it differently if necessary.

timestamp|type|uri|referer|user_id|link|message
Feb  5 23:58:29 181d5d6339bd drupal_overlake: 1612569509|geocoder|https://overlake.lando/admin/config/development/configuration/config-split/add|https://overlake.lando/admin/config/development/configuration/config-split/add|0||Could not execute query "https://maps.googleapis.com/maps/api/geocode/json?address=L-054%2C%20US&language=&region=US".
Feb  5 23:58:29 181d5d6339bd drupal_overlake: 1612569509|geocoder|https://overlake.lando/admin/config/development/configuration/config-split/add|https://overlake.lando/admin/config/development/configuration/config-split/add|0||Unable to geocode 'L-054, US'.
1 Answers

You can't do it with the -f option to tail. column can't produce any output until it receives all its input, since it needs to calculate the number of rows and columns by examining all the input. tail -f never stops writing, so column doesn't know when it's done.

You can use

tail -n 100 test.log | column -t -s "|"

to format the last 100 lines of the log.

Related