1

I'm using clip to set text on the clipboard. To do that, I use echo.

echo Works|clip

The problem is when the text contains special characters, eg. | ".

echo (TRUE|FALSE)|clip
echo " is a Quote Mark|clip

How should the text for echo be escaped? Is there a better way to set text to the clipboard?

Adamarla
  • 113

1 Answers1

0

How should the text for echo be escaped?

Use the ^ escape character.

When piping to clip, the ^ needs escaping as well.

Example 1:

> echo (TRUE^^^|FALSE)|clip

Contents of clipboard:

(TRUE|FALSE)

Example 2:

> echo ^" is a Quote Mark|clip

Contents of clipboard:

" is a Quote Mark

Escape Character

^ Escape character.

Adding the escape character before a command symbol allows it to be treated as ordinary text.

When piping or redirecting any of these characters you should prefix with the escape character: & \ < > ^ |

Example:

^\  ^&  ^|  ^>  ^<  ^^

Source Quotes, Escape Characters, Delimiters - Windows CMD - SS64.com


Further Reading

DavidPostill
  • 162,382