Quick Creation of Text Files From the Command Line
It's a sunny day here in the Seattle area, so let's have some command line fun. :)
Have you ever needed to create a small text file while working at a command line? I've been using the following technique since my MS-DOS days.
Creating files at the command line is very simple, using the copy
command. Here's how:
- While in a Command Prompt window, navigate to your desired folder. I will use c:\test in this example.
C:\> cd test
- Instruct the
copy
command to copy the console (CON) data to your file (ex: notes.txt)
C:\test> copy con notes.txt
- Type your desired text
This is a simple file created via the copy command
- Save the file using
Ctrl+Z
and pressing theEnter
key
The console window will show the following
^Z 1 file(s) copied.
If you decide you do not wish to create the file, you can cancel using Ctrl+C
and pressing the Enter
key.
It is important to note that once you press the Enter
key (on any line of your file), it is not possible to go back and make changes. For this reason, for any file longer than a line or two, I don't recommend this technique. I suggest using Notepad or your favorite text editor instead.
I was searching the Microsoft Help and Support site while writing this and found the following additional tip:
Appending a Line to a File with COPY Con or ECHO
This tip is extremely cool if what you are looking to do is add a line or two to an existing file.
Enjoy!
-- DK
Disclaimer(s):
This posting is provided "AS IS" with no warranties, and confers no rights.
Comments
- Anonymous
February 09, 2006
The comment has been removed