By default, the echo command adds a new line character to its output. For example, if you print some environment variable, the output will be appended with an extra line. The extra line can create a problem if you wish to copy the output to the clipboard to be used in another command. Today we will see how to get rid of the new line character in the echo command output at the command prompt.
There are several scenarios when you wouldn't want the additional line. For example, if you are using a combination of "clip" and "echo" commands as described in the article How to copy the command prompt output directly to the Windows clipboard, the new line character will be a hindrance.
To remove it from the output, use the following syntax:
echo | set /p=some text or variable
echo | set /p=some text or variable|clip