How to make the echo command without new line in Windows

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.

echo userprofile
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

For example:
echo no new line
In case you need to use such syntax with the clip command, you need to use it as follows:

echo | set /p=some text or variable|clip

No new line character will be present in the clipboard:
notepad no new line
That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!


Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

3 thoughts on “How to make the echo command without new line in Windows”

  1. The pipe is very slow as it creates two extra cmd-tasks, faster is <nul set /p =Hello. set /p can't echo an equal sign as first character nor spaces/tabs. – jeb Aug 18 '11 at 18:23

    1. Thank you! <nul set /p=my text

      This worked in my project to output text to .js files from a batch with no leading/trailing spaces

Leave a Reply

Your email address will not be published.

Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.