Computing.Net > Forums > Programming > Batch files and special characters

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch files and special characters

Reply to Message Icon

Name: bussumarus
Date: September 2, 2008 at 03:08:13 Pacific
OS: Windows XP
CPU/Ram: Some
Product: Custom built
Comment:

I am trying to create a batch file which echos data to a text file using something like:
echo mytext >> file.txt

The problem is, when I use certain characters I get errors.
For example:
echo my test &5 >> file.txt
For this I get the error message "'5' is not recognized as an internal or external command, operable program or batch file."

This issue is clearly caused by the & character. Is there an escape character sequence I need to use to echo this character. Putting & between 2 " works, but the text file needs it without.
Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: September 2, 2008 at 03:24:13 Pacific
Reply:

The caret is used an escape character.

echo my test ^&5 >> file.txt


0

Response Number 2
Name: IVO
Date: September 2, 2008 at 03:29:24 Pacific
Reply:

Characters with special meaning for the interpreter must be prefixed by a caret (^) to behave as normal ones. so type ^&.

Other special symbols for cmd.exe are | < > and in rare case !.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch files and special characters

Batch files and serial ports? www.computing.net/answers/programming/batch-files-and-serial-ports/16989.html

Make an exe with a batch file and.. www.computing.net/answers/programming/make-an-exe-with-a-batch-file-and/17595.html

i created a batch file and i'm invoking three www.computing.net/answers/programming/i-created-a-batch-file-and-im-invoking-three/19013.html