This tip was printed from the MalekTips Computer and Technology Help and Tips website at http://malektips.com.

Windows XP and DOS - UNIX Style Less Command

SUMMARY: Scroll through text files inside the Windows XP DOS prompt with a command similar to UNIX's less command.

The less command, on most UNIX-style operating systems, displays the contents of a text file, but in a different fashion than the more command. Instead of only allowing one-way scrolling through a file, less uses the entire terminal window to display a text file and allows for interactive bi-directional scrolling. The less command has other interactive features, allowing one to search for matching text.

Windows XP has an equivalent to this command called list. While not 100% functionally-equivalent to most versions of the UNIX less command, list does support text searching and bi-directional scrolling. This command is useful when examining log files (such as web server logs), configuration files, and software "read me" files when you don't want to open a Notepad window.

While Notepad will typically load a full file into memory, if you need to view log files containing multiple gigabytes of data, the list command only buffers up to (by default) 200k of information at a time.

To use the list command, you'll need to first download and install the Windows 2003 Resource Kit.

The list command supports the following command-line options:

filename
REQUIRED - The filename you wish to view

-s:STRING
Performs a case insensitive search and highlights the first line matching your search text

-g:LINE#
The list display will jump to the specified line number, displaying it at the bottom of the screen. Note that list starts its line numbering from line 0.

Examples:

The following command examines the Windows Update log file to determine when/if update 917344 was applied, MS06-023: Vulnerability in Microsoft JScript could allow remote code execution.

list %WINDIR%\windowsupdate.log -s:917344

The following command examines the log file for Microsoft update 917344, jumping to line 168. Depending on your configuration, this may jump to the end of the file, showing that the update required a reboot of your machine.

list %WINDIR%\kb917344.log -g:168

While running the list command, here are a few of the functions you may perform:

Cursor keys
Use the cursor keys to scroll through the file. If the file is too wide to view onscreen at once, the left and right cursor keys will be active.

Page Up, Page Down Keys
Scrolls through the text file up or down one page at a time

Home, End Keys
Jumps to the beginning or end of the file

W
Toggles text word-wrap

Q or the ESC key
Quits the list display

/
Perform a case-sensitive search of the string you specify

\
Perform a case-insensitive search of the string you specify

n or F3
Searches for the next match to the search string

N
Searches for the previous match to the search string

G
Jump to the specified line number

F
Open a new file without going back to the DOS prompt

?
Displays a full list of commands

Note that by entering more than one filename after the list command you can view more than one file. Although only one file is displayed at a time, the following commands switch between files specified on the command line:

CTRL PAGE-DOWN
Displays the next file specified on the command line, or wraps to the first file.

CTRL PAGE-UP
Displays the previous file specified on the command line, or wraps to the last file.


 


Press the "print" button on your browser or select "File" - "Print" to print this tip. Then, return to Windows XP and DOS - UNIX Style Less Command
 
Standard disclaimer applies - read http://malektips.com/disclaim.html.