suppress carriage return with echo

D

destatnj2

Hi All,

Is there a way to suppress the carriage return that is inserted after an
echoed statement?
For instance, something like:

echo Hey
echo you

that would output:

Thanks,

Pete
 
P

Paul R. Sadowski

My version of echo will do that.

I forgot to document it on the webpage but use the N switch to prevent a
CRLF at the end of a line, like this:

C:\Users\sadowski [(firecat) 12:10, Mon 03/29/2004] \bin\echo.exe -n "Hey "
& \bin\echo.exe you
Hey you

Echo.exe
Echo echoes characters from the command line to the standard output. Unlike
the built-in version of echo this version allows you to specify printf
escape sequences (such as \n for a newline) and octal representations of
characters.

\b BACKSPACE
\c Print line without NEWLINE
\f FORMFEED
\n NEWLINE
\r RETURN
\t TAB
\v vertical TAB
\\ backslash
\x the 8-bit character whose ASCII code is the 1-, 2-, 3- or 4-digit octal
number x. The first digit must be zero.

Example usage:

C:\echo.exe %TIME%\n%DATE%
16:25:13.03
Fri 02/06/2004



http://www.paulsadowski.com/WSH/cmdprogs.htm
 
D

destatnj2

Thanks for the reply Paul,

Do you know of a way/trick using only internal commands? This will be used
on someone else's computer who will not have your modified echo. Or maybe
you could post the portion of your echo that deals with cr/lf suppression?
Thanks,

Pete

Paul R. Sadowski said:
My version of echo will do that.

I forgot to document it on the webpage but use the N switch to prevent a
CRLF at the end of a line, like this:

C:\Users\sadowski [(firecat) 12:10, Mon 03/29/2004] \bin\echo.exe -n "Hey "
& \bin\echo.exe you
Hey you

Echo.exe
Echo echoes characters from the command line to the standard output. Unlike
the built-in version of echo this version allows you to specify printf
escape sequences (such as \n for a newline) and octal representations of
characters.

\b BACKSPACE
\c Print line without NEWLINE
\f FORMFEED
\n NEWLINE
\r RETURN
\t TAB
\v vertical TAB
\\ backslash
\x the 8-bit character whose ASCII code is the 1-, 2-, 3- or 4-digit octal
number x. The first digit must be zero.

Example usage:

C:\echo.exe %TIME%\n%DATE%
16:25:13.03
Fri 02/06/2004



http://www.paulsadowski.com/WSH/cmdprogs.htm

destatnj2 said:
Hi All,

Is there a way to suppress the carriage return that is inserted after an
echoed statement?
For instance, something like:

echo Hey
echo you

that would output:


Thanks,

Pete
 
G

Guest

Perhaps you could do this sort of thing:

set echotext=Hey
set echotext=%echotext% you
echo %echotext%

You could also search for a Win32 port of various Unix utilities - there is an
"echo" which has an option to leave off the endline (you may need to rename it
from echo.exe to something else, if you don't want to get it mixed up with the
built-in echo command. There is also a "printf" command that allows for more
formatting (like the C printf function).

One place (among many, many others) that may have these:

http://unxutils.sourceforge.net/


|Hi All,
|
|Is there a way to suppress the carriage return that is inserted after an
|echoed statement?
|For instance, something like:
|
|echo Hey
|echo you
|
|that would output:
|
|>Hey you
|
|Thanks,
|
|Pete
 
B

Bill Stewart

Hi Pete,
Do you know of a way/trick using only internal commands?

AFAIK, this is not possible. Echo always adds a CR/LF.
This will be used on someone else's computer who will not have your
modified echo.

Then you will need to distribute the executable with the batch file.
Or maybe you could post the portion of your echo that deals with cr/lf
suppression?

(?) I fail to understand how that could help...Paul's program is a custom
executable...

Regards,

Bill
 
D

destatnj2

Thank you all for your replies,

Bill,
(?) I fail to understand how that could help...Paul's program is a custom
executable...

I thought I might be able to paste the source snippet right into my batch,
but you're right, that wouldn't work especially if it was written in a
different language which I'm assuming it must have been now that I think
about it. Anyways, this question was purely for aesthetic formatting
reasons and is not critical.

Thanks to everyone,

Pete
 
P

Phil Robyn [MVP]

destatnj2 said:
Hi All,

Is there a way to suppress the carriage return that is inserted after an
echoed statement?
For instance, something like:

echo Hey
echo you

that would output:




Thanks,

Pete

- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>demo\NoCRLF
Hey you.
C:\cmd>rlist demo\NoCRLF.cmd
=====begin C:\cmd\demo\NoCRLF.cmd ====================
1. @echo off
2. echo/|set /p =Hey
3. echo/|set /p = you.
=====end C:\cmd\demo\NoCRLF.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -
 
P

Phil Robyn [MVP]

destatnj2 said:
Hi All,

Is there a way to suppress the carriage return that is inserted after an
echoed statement?
For instance, something like:

echo Hey
echo you

that would output:




Thanks,

Pete

Here's another one:

- - - - - - - - - - begin screen capture Win2000 - - - - - - - - - -
C:\cmd>demo\NoCRLF3 the quick brown fox jumps over the lazy dog.
the quick brown fox jumps over the lazy dog.
C:\cmd>rlist demo\NoCRLF3.cmd
=====begin C:\cmd\demo\NoCRLF3.cmd ====================
1. @echo off
2. for %%a in (%*) do (
3. echo/|set /p ="%%a "
4. )
=====end C:\cmd\demo\NoCRLF3.cmd ====================
- - - - - - - - - - end screen capture Win2000 - - - - - - - - - -
 
P

Patrick Bonneau

Why dont U just use variable to find what you want and
then echo the variable side by side... echo %a% %d% work
fine too
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top