How to Read a File From Windows Command Line

How to open, view, and edit the contents of a file on a computer

Updated: 12/31/2020 by Reckoner Promise

Tip

A file may be compiled or created simply to be viewed by a item program. The examples beneath open a obviously text file. If the file looks like garbage when opened, the plan is non capable of viewing the file. Make certain the program you need to open up the file is installed and associated with the file type. If you don't know what programme to utilize, determine the file extension and review our file extensions page for a listing of associated programs.

Select your operating system in the listing below for instructions on viewing the contents of a plain text file.

Microsoft Windows users

Double-click the file that y'all want to open. The programme associated with the file opens that file.

Tip

You tin can open multiple files, such every bit Word documents, Excel spreadsheets, plain text files, PDF files, and more, at the same fourth dimension. The associated programs open each file and display them on the computer screen.

If the file is unassociated with a plan, you lot will receive an "Open With" prompt. If you don't know which program to use, attempt using WordPad or Notepad.

  • Why do I get an 'Open up with' window when opening a file?

If the file is associated with a plan, but yous desire to use a different program, concur downwardly the Shift and right-click the file. Select Open With from the drop-down menu that appears, and then select the program you desire to use to open the file.

Open with

Alternative method

  1. Open the program y'all desire to use to view the file. For instance, if you wanted to view the file in Microsoft Discussion, you lot would open it first.
  2. One time the program is opened, from the file carte, select Open or utilise the keyboard shortcut Ctrl+O.
  3. In the Open window, browse to the location of the file, select the file, so click OK or Open up.

Tip

Windows users can also use the methods mentioned beneath to open a file using the Windows command line.

MS-DOS and Windows command line users

List files

If you lot need to view a list of bachelor files in the electric current directory, you can use the dir control.

Edit command

Locate the file that you want to view. The instance below, nosotros are opening the file autoexec.bat in the current directory.

edit autoexec.bat

Note

If the file does non exist, was entered improperly, or is empty, a blank window similar to the example below is shown.

MS-DOS Editor edit command window

In one case you have edited the file or typed the information for the file, click File, and choose Exit. If you do non accept a mouse, come across the edit command page for keyboard shortcuts and other navigation tips.

Later on clicking exit, if whatever changes were made, y'all'll exist asked if y'all want to save the file. Click Yes to finalize your changes.

  • See our edit command page for farther information on this control.

Kickoff command

New, 64-bit versions of Windows no longer back up the edit command. You lot can too use the outset command to open a file in a text editor, such every bit Notepad, using the following command.

showtime notepad hope.txt

In the example above, if the file "hope.txt" did not exist in the current directory, you are prompted to create a new file.

The starting time command can besides exist used to open up any file on your computer. For instance, if you accept Microsoft Discussion installed on the computer and want to open up a Word certificate from the command line, you lot would enter the following:

start promise.medico
  • Run across our start command page for further information.

Type command

If you but want to view the contents of the file, yous can also use the type command:

blazon hope.txt

In the example above, the command would brandish all of the contents of the hope.txt to the file. If the file is a large file, information technology will keep scrolling unless you lot press the interruption fundamental. For big files, you tin can likewise pipe the command to more than as shown in the example below.

type hope.txt | more than

In the previous example, the type command displays the contents ane page at a fourth dimension. Pressing the Enter will advance the output one line at a fourth dimension and pressing the spacebar advances one page at a fourth dimension.

  • In MS-DOS, you can also use the type control to brandish the contents of a text file.

Copy con

If you cannot use whatsoever of the methods above, you lot tin also use copy con to create a file.

copy con hope.txt

Once you have entered the above command, the hope.txt file is created.

After you have typed all the lines, y'all want to exist in the file, printing and hold Ctrl+Z. Afterward ^Z is shown on the screen, printing Enter to save the file.

Notation

The copy con method just creates a basic file. It does not allow yous to edit a file or go back and fix any errors fabricated while creating a line in the file.

macOS users

On a Mac computer, you tin can double-click a file to open the file in the software programme associated with the type of file yous are opening. Once the file is opened, yous can view the contents of the file and brand changes to it.

You can too open a file past selecting information technology on the desktop, or in the Finder awarding. Then press the Command + downwards arrow key.

Microsoft Windows Explorer

Windows users have an actress utility in the way of Explorer. Whatsoever file you need to detect can be searched through it. Press the Windows central and "E" at the same to access Windows Explorer.

Unix and Linux users

List files

If you need to view a list of bachelor files in the current directory, you lot can use the ls command.

Opening, creating, editing, and viewing files in Linux

Considering of all the available options for each Linux variants nosotros've given this department a page of its own in the following link.

  • How to open, create, edit, and view a file in Linux.

thomasonvorcy1981.blogspot.com

Source: https://www.computerhope.com/issues/ch000429.htm

0 Response to "How to Read a File From Windows Command Line"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel