Windows 7 / Getting Started

Escaping Special Characters

As you've already seen, the following characters have special meaning to CMD:

< > ( ) & | , ; "

If you need to use any of these characters as part of a command-line argument to be given to a program (for example, to have the find command search for the character >), you need to escape the character by placing a caret (^) symbol before it.This indicates that the character is to be treated like any other character and removes its special meaning.To pass a ^ character as an argument, type ^^.

For example, the echo command types its arguments in the Command Prompt window. The command

echo <hello>

causes a problem because CMD thinks you want to redirect input from a file named hello and that you want to redirect output to...well, there is no filename after >, so CMD would print an error message. However, the command

echo ^<hello^>

prints <hello>.

[Previous] [Contents] [Next]