Tag Archives: cmd

Emulating *nix Shell with Windows Command Prompt

Ever tried to ls or rm under Windows?

With just a few minor adjustments the Windows Command Prompt (cmd.exe) can emulate the behaviour of your favourite *nix shell. Please note, this isn’t a full emulation method – the existing Windows commands are being manipulated to appear as their *nix shell counterparts.

Note: This is for systems where unauthorized software is not permitted. If you administrate your own system, I highly recommend checking the GnuWin32, in particular the CoreUtils package.
Continue reading Emulating *nix Shell with Windows Command Prompt

Write console text to a file (Windows cmd.exe)

Writing directly from the Windows command line to a file might not be something you need to do very often. The famous black and white console is better suited to serving system commands and file operations than being a stand-in for notepad. However, it is sometimes useful to have the option of writing multiple lines of text to a file directly from the trusty prompt.

Method One

This is suitable for creating/overwriting a file with multiple lines of text.

copy con SOME_FILE.txt
Type your text here
You can even have multiple lines!

When finished, press CTRL+Z to confirm your action (or CTRL+C to cancel) and ENTER.

If you want to append some text instead of overwriting it completely, follow as above but using:

copy SOME_FILE.txt + con

Method Two

Open up the command prompt and type:


This method creates/overwrites SOME_FILE.txt with the text you entered before the >. It is only suitable for entering a single line of text into a file.

As with method one, it possible to append text using >> instead of > in the command.