To configure the command prompt

To configure the command prompt

1. Open Command Prompt

2. Click the upper-left corner of the Command Prompt window, and then click

3. Click the Options tab.

4. In Command History, type or select 999 in Buffer Size, and then type or
select 5 in Number of Buffers.

5. In Edit Options, select the Quick Edit Mode and Insert Mode check boxes.

6. Click the Layout tab.

7. In Screen Buffer Size, type or select 2500 in Height.

8. Do any of the following optional tasks:

• In Screen Buffer Size, increase Width.
• In Window Size, increase Height.
• In Window Size, increase Width.
• Clear the Let system position window check box, and then, in Window
Position, change the values in Left and Top.

9. In the Apply Properties dialog box, click Save properties for future windows
with same title.

• To open command prompt, click Start, point to All Programs, point to
Accessories, and then click Command Prompt.
• To open Command Prompt Properties from the keyboard, press ALT+SPACEBAR+P.
• By selecting the Quick Edit Mode check box, you enable copy and paste from
the Command Prompt window. To copy, select the text in the Command Prompt
window with your left mouse button, and then right-click. To paste, either
at the command prompt or in a text file, right-click.
• By increasing the screen buffer size to 999, you enable scrolling through
the Command Prompt window.
• By increasing the number of buffers to five, you increase the number of
lines in the Command Prompt window to 5000.
• To enable or disable file and directory name completion on a computer or
user logon session, run Regedit.exe and set the following REG_DWORD value:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD

To set the REG_DWORD value, use the hexadecimal value of a control character for
a particular function (for example, 0×9 is TAB and 0×08 is BACKSPACE).
User-specified settings take precedence over computer settings, and command-line
options take precedence over registry settings. For more information about file
and directory name completion, see Related Topics.


How Can I Eliminate Duplicate lines in a Text File?

from Microsoft TechNet article Hey, Scripting Guy!

1. do following–

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Usage: CScript scriptname.extension [option...] [arguments...]

//B Batch mode: Suppresses script errors and prompts from displaying
//D Enable Active Debugging
//E:engine Use engine for executing script
//H:CScript Changes the default script host to CScript.exe
//H:WScript Changes the default script host to WScript.exe (default)
//I Interactive mode (default, opposite of //B)
//Job:xxxx Execute a WSF job
//Logo Display logo (default)
//Nologo Prevent logo display: No banner will be shown at execution time
//S Save current command line options for this user
//T:nn Time out in seconds: Maximum time a script is permitted to run
//X Execute script in debugger
//U Use Unicode for redirected I/O from the console

This is the command we would use to run windows script.

2. here is the script

Const ForReading = 1

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile _
("c:\scripts\namelist.txt", ForReading)

Do Until objFile.AtEndOfStream
strName = objFile.ReadLine
If Not objDictionary.Exists(strName) Then
objDictionary.Add strName, strName
End If


For Each strKey in objDictionary.Keys
Wscript.Echo strKey

3. copy this script and save as file, test.vbs

4. on command promp, type

C:\>cscript //Nologo test.vbs > unique.lines.txt

5. unique.lines.txt file would have all the duplicate lines removed.

(I’ve tested this code on Windows 2000)

Windows 2000 grep

Windows 2000 have something like grep —

C:\>findstr /?
Searches for strings in files.

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes]
[strings] [[drive:][path]filename[ ...]]

/B Matches pattern if at the beginning of a line.
/E Matches pattern if at the end of a line.
/L Uses search strings literally.
/R Uses search strings as regular expressions.
/S Searches for matching files in the current directory and all
/I Specifies that the search is not to be case-sensitive.
/X Prints lines that match exactly.
/V Prints only lines that do not contain a match.
/N Prints the line number before each line that matches.
/M Prints only the filename if a file contains a match.
/O Prints character offset before each matching line.
/P Skip files with non-printable characters
/A:attr Specifies color attribute with two hex digits. See "color /?"
/F:file Reads file list from the specified file(/ stands for console).
/C:string Uses specified string as a literal search string.
/G:file Gets search strings from the specified file(/ stands for console).
/D:dir Search a semicolon delimited list of directories
strings Text to be searched for.
Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C. For example, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

Regular expression quick reference:
. Wildcard: any character
* Repeat: zero or more occurances of previous character or class
^ Line position: beginning of line
$ Line position: end of line
[class] Character class: any one character in set
[^class] Inverse class: any one character not in set
[x-y] Range: any characters within the specified range
\x Escape: literal use of metacharacter x
\ Word position: end of word

For full information on FINDSTR regular expressions refer to the online Command




gzip file using java

Searching in gzip file using java was way too easy then I thought–

    public static void gzipTest(String gzFileName,
            String outFileName) 
        throws Throwable { 
        File gzFile = new File(gzFileName);
        BufferedReader reader = null;
        reader = new BufferedReader(
            new InputStreamReader(
            new GZIPInputStream(
            new FileInputStream(gzFile))));
       BufferedWriter writer = null;
       writer = new BufferedWriter(new FileWriter(outFileName));
       String line = null;
       while( null != (line = reader.readLine()) ) {
       reader.close(); reader = null;
       writer.close(); writer = null;