I would like to see how I can use, or escape pipeline in a back quote in windows batch just like in Unix shells. Suppose I have this:
FOR /F "usebackq delims=" %i IN (`date /t`) DO @set TODAY=%i
echo %TODAY%
This will give me the date in TODAY variable. But I want to have this 1 or more pipeline working:
FOR /F "usebackq delims=" %i IN (`date /t | cut -c 1-3`) DO @set TODAY=%i
cmd.exe complains err like this I think I need an escape mechanism?
| was unexpected at this time.
So, is this doable? How? Please note that I have full gnu coreutils and most goodies in PATH so I can use cut just as example.
The escape character is
^
.Here is the command, with
set
replaced byecho
at the end to make it SO friendly.(YMMV, I have a French locale for date)