Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to echo a greater than sign in a batch file

10,897 views
Skip to first unread message

Todd and Margo Chester

unread,
Apr 19, 2006, 7:48:37 PM4/19/06
to
Hi All,

This is not a question. I am writing this for Google
to save it for others. (It took me forever to find a reference
to it.)

From
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/echo.mspx?mfr=true

To display a pipe (|) or redirection character (< or >) when
using the echo command, use a caret character immediately before
the pipe or redirection character (for example, ^>, ^<, or ^| ).
If you need to use the caret character itself (^), use two in a row (^^).

example:

echo dir %%1 /-p /o:gn ^> "%%temp%%\Listing" >> %windir%\Printdir.bat

I hope this helps someone else.

--Todd

Timo Salmi

unread,
Apr 20, 2006, 12:48:38 AM4/20/06
to
Todd and Margo Chester wrote:
> This is not a question. I am writing this for Google
> to save it for others. (It took me forever to find a reference
> to it.)
> From
> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/echo.mspx?mfr=true

Ok, good. That information is readily available also off-line:
hh ntcmds.chm::/echo.htm

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

rheffels

unread,
Apr 20, 2006, 4:17:06 AM4/20/06
to

Timo Salmi

unread,
Apr 20, 2006, 10:31:05 AM4/20/06
to
rheffels wrote:
> More links here:

And off-line here:
hh C:\WINDOWS\Help\ntcmds.chm

mike.j...@gmail.com

unread,
Apr 20, 2006, 12:26:36 PM4/20/06
to
The prefacing of certain characters with a caret thus

echo ^> this is a greater than symbol

is called "escaping" the character. I thought it was very widely known,
but apparently not.

Si Ballenger

unread,
Apr 20, 2006, 5:56:27 PM4/20/06
to

Seems to be a "google groups" thing. Much discussed in the usenet
group in the past.

K. McGee

unread,
Sep 24, 2006, 8:35:55 PM9/24/06
to


I guess it is widely known amongst the experienced.
Thankfuly subjects re-occur for us newbies.

Came here looking for an answer to a different problem,
but this enlightenment is appreciated.

Thanks all.

K. McGee

Si Ballenger

unread,
Sep 24, 2006, 10:06:39 PM9/24/06
to

Timo has a collection of previous news group post in the below
zip file that cover a lot of batch how-to-do-its.

ftp://garbo.uwasa.fi/pc/link/tscmd.zip

rav...@gmail.com

unread,
Nov 18, 2015, 2:30:34 AM11/18/15
to
This really helps.. .stumbled upon when i wanted to display a >> symbol. But when I tried doing the same for percentage symbol i had to struggle. ^% didn't work. I tried a work around like

when i had to %ERRORLOG% as a text, it didnt work.. so was playing around and finally got it.. its fun but confusing..
@echo off
SET P1=%%
echo %p1%ERRORLOG%p1%
echo %%ERRORLOG%%

foxidrive

unread,
Nov 18, 2015, 3:02:53 AM11/18/15
to
On 18/11/2015 18:30, rav...@gmail.com wrote:
> On Thursday, April 20, 2006 at 5:18:37 AM UTC+5:30, Todd and Margo Chester wrote:
>>
>> To display a pipe (|) or redirection character (< or >) when
>> using the echo command, use a caret character immediately before
>> the pipe or redirection character (for example, ^>, ^<, or ^| ).
>> If you need to use the caret character itself (^), use two in a row (^^).
>>
>>
>> --Todd
>
> This really helps.. .stumbled upon when i wanted to display a >> symbol. But when I tried doing the same for percentage symbol i had to struggle. ^% didn't work.

echo %%
is how to echo a percent sign.

Konrad Kullig

unread,
Nov 18, 2015, 11:49:18 AM11/18/15
to
When you want to output any text stored in an environment variable (any
means there meight be characters like '>', '|' ...) you can do this:

Instead of:
echo %MyText%

use:
echo.|set /p "=%MyText%" & echo.

tarik.ha...@gmail.com

unread,
Apr 26, 2016, 12:30:53 AM4/26/16
to
On Thursday, April 20, 2006 at 5:18:37 AM UTC+5:30, Todd and Margo Chester wrote:
Thanks Todd. I was trying to figure it out & when I googled I got your post in the first search result. keep doing good work.

alan...@gmail.com

unread,
Jun 1, 2016, 10:36:20 PM6/1/16
to
Thank you very much!! You helped me a lot!!
I was tired of searching the answer.

easy...@gmail.com

unread,
Apr 16, 2018, 4:41:30 PM4/16/18
to
Omg, thanks. I was in a world of pain with groovy/jenkins. This saved me.

shifty....@gmail.com

unread,
Aug 21, 2019, 7:24:03 PM8/21/19
to
0 new messages