BATCH: Like an echo line containing '&' char to a file

I am trying to write a URL string to the file containing the '&' char in it (using a simple "echo"), the problem is that it saved the char on the command line so that it does not work.

Is there a way to tell the command line that it is part of a line.

Example:

echo www.google.com/search=make&peace > love.txt 

I will get an error indicating that the β€œworld” is not a recognized team.

Thanks!

+4
source share
2 answers

cmd uses ^ as an escape character, so

 echo www.google.com/search=make^&peace > love.txt 
+14
source

Just provide the URL in quotes:

 echo "www.google.com/search=make&peace" > love.txt 
+5
source

Source: https://habr.com/ru/post/1383760/


All Articles