Your Ad Here

IBM AIX/UNIX system storage administration ksh/perl scripting

Tuesday, July 08, 2008

Reverse the Contents of File using Perl

You have a log file or whatever file that is in chronological order (oldest record first, the newest records last). And you want to reverse the order.

There is a function in Perl aptly named "reverse" that can perform the task for you.

# cat logfile
1
2
3

# perl -e 'print reverse <>;' logfile
3
2
1

No comments:

Labels

BlogCatalog