≡ Menu

Open text file from command line

On  a Windows machine, we can open a text file from command prompt by just giving the file name.
For example to open a text file named file1.txt, we just need to type file1.txt in the command prompt and press ‘Enter’. 

c:> file1.txt

Note that file name should have the extension as .txt otherwise command prompt would not be able to identify which application need to be used to open the file.

9 comments… add one
  • sumit

    .\filename.txt
    then hit enter.

  • Suman Ghosh

    more filename

  • Marvi Sharma

    Thank you. Your material proved to be very helpful.

  • Nkavelo

    I’m struggling to open a two word file.
    Some files have underscores and hyphens, how do I open those?

    • Anonymous

      Write ” Around the address name.
      Example:

      “C:\Users\User 1\Downloads\ChromeSetup.exe”

  • vikaz baig

    which command is used to show the contents of text file?

    • No One Special

      In command prompt, use the command TYPE to view the contents of the text file.

      i.e. type C:\windows\system32\drivers\etc\hosts

  • Microsoft Help

    This is a good way to create a Msge box in CMD

  • Mujaahid

    how to open many file and folder to text editor with terminal?, example i want to open laravel framework to text editor

Leave a Comment