Read file from command line

by admin on January 1, 2009

We can read a text file from command line using type command. This command is similar to cat command on Linux.

Example: Let us print the contents of the file c:\boot.ini

C:\>type c:\boot.ini
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Home Edition"

If the file is very huge, we can use more command to read the data one page at a time. This more command is pretty much similar to the Linux more command.

Syntax of the command is:

more  filename

This command will print one page text on the console and will wait for the user to press Enter before it shows the next page.

The above explained commands work in XP, Vista, Windows7, Server 2003 and Server 2008 versions.

{ 3 comments… read them below or add one }

Anonymous October 11, 2010 at 1:12 pm

Very thanks! :)

Reply

Anonymous November 3, 2010 at 12:14 pm

Is there any command to read only the last two lines of a file?

Reply

Techblogger November 3, 2010 at 2:29 pm

We can do it using tail command. Read the post Tail command for windows

Reply

Leave a Comment

HTML tags are not allowed.

Previous post:

Next post: