You are on page 1of 1

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

You might also like