Removing a token with an obscure trick

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jeb
Expert
Posts: 1062
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Removing a token with an obscure trick

#1 Post by jeb » 24 Nov 2011 08:54

Hi,

I know this trick for a long time, but I can't found any useful application for it. :wink:

But perhaps have anyone else an use case. :D

Code: Select all

@echo off
echo One two three ^
four

echo One two three^
 four

echo One two<nul three ^
four

echo One two<nul three^
 four


Output wrote:One two three four
One two three four
One two three four
One two four
As you can see in the fourth line the word/token "three" is removed, this is an effect of the redirection and a token just before a multiline caret.
This effect is not related to the ECHO, it works always.

It can strip a single token from a string like here

Code: Select all

set var=one two <nul "this & that"^
three
set var

Output wrote:one two three


But currently I didn't know what problem can be benefit by this :(

jeb

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Removing a token with an obscure trick

#2 Post by phillid » 29 Dec 2011 19:17

Maybe it could be used for commenting-out things in a weird way? :|

Post Reply