less, the GNU utility that resembles the classic UNIX more command, has capabilities you might not be aware of. Sure, it will page through files, but have you ever tried the following?
These commands are equivalent to the following, respectively:less somefile.tar.gz less somefile.tar.bz2 less somefile.zip less somepackage.rpm
In all these cases, less provides the same function with less typing. The following command is very familiar to Linux and UNIX system administrators:tar ztvf somefile.tar.gz | less tar jtvf somefile.tar.bz2 | less unzip -l somefile.zip | less (rpm -qpi somepackage.rpm; rpm -qpl somepackage.rpm) | less
For the uninitiated, this command displays the system log (/var/log/messages), and updates the display as new entries are written to the log. For example, you might run a tail -f like the one above on a DHCP server to see DHCP requests and acknowledgments as they happen. Sometimes, however, you not only want to have the display updated, but you also want to scroll back through the output periodically. less provides this capability. First, less the file that you wish to monitor (this could also be output that has been passed through a pipe to less):tail -f /var/log/messages
Now type Shift-f. The display will immediately go to the bottom of the file and you will see a line like the following below the output:less /var/log/messages
As new data enter the log, the display will update. less will remain in this mode until you type ^c.Waiting for data... (interrupt to abort)
- sandip's blog
- Login or register to post comments
Comments
Here's a trackback to the folks at summersault.com !