Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to add the simpliest tag into a file, using a CMD batchfile, but it seems that the double quotes are spoiling the party:

From other StackOverflow posts I am aware of the double quote state machine and the usage of ^" (^ as an escape character). Still I can't make it work:
Hereby my attempts (with their results):

C:>echo <tag variable="value">  // very na?ve
The syntax of the command is incorrect.

C:>echo "<tag variable="value">"  // let's use quotes for delimiting the string
"<tag variable="value">"

C:>echo "<tag variable=^"value^">" // let's use the escape character
The system cannot find the path specified.

C:>echo "<tag variable=^"value^"> // what if the state machine is not switched back?
The syntax of the command is incorrect.

C:>echo "<tag variable=^"value"> // desperate people do weird things :-)
"<tag variable=^"value">

I have also done some tests using the escape character in front of the tag characters < and > (as those have their own significance in CMD) but also there no good results.
Also first putting the entry within a variable (set test="...") does not solve the issue.
As mentioned, I am getting desperate. The only thing I want to do is writing this into a text file:

<tag variable="value">

Can anybody help me out here?
Thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
835 views
Welcome To Ask or Share your Answers For Others

1 Answer

the characters you want to escape are not the " but the <.
Then the correct syntax is this one :

C:>echo ^<tag variable="value"^>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...