Cat your logs backwards to preserve the date order

Posted in Linux

I learned a new command today. It was such a simple one, I can’t believe i’ve never heard of it before or seen anyone else use it.

It’s nice to be able to ‘cat’ dated logs that are split into multiple files with a simple command

cat /var/log/messages*

but that leaves you with the dates mixed up. There’s an easy solution: cat, backwards!

tac /var/log/messages*

Tada.

From the man page:

NAME
tac - concatenate and print files in reverse

SYNOPSIS
tac [OPTION]… [FILE]…

DESCRIPTION
Write each FILE to standard output, last line first. With no FILE, or when
FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.

-b, –before
attach the separator before instead of after

-r, –regex
interpret the separator as a regular expression

-s, –separator=STRING
use STRING as the separator instead of newline

–help display this help and exit

–version
output version information and exit

Posted by admica   @   29 May 2009
Tags : , , ,

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« How do you answer Secret Questions for password resets?
Next Post
My favorite new features coming to Fedora 11 »
Powered by Wordpress   |   Lunated designed by ZenVerse