Home > OS >  How to send a command with arguments without spaces in Windows
How to send a command with arguments without spaces in Windows

Time:01-05

Is there a way to execute a command with arguments in Windows without spaces?

echo 1 > a

Needs to be:

echo1>a

In Linux you can use ${IFS} but I didn't find it to work in Windows:

echo${IFS}1${IFS}>a

CodePudding user response:

Does this produce what you are seeking?

ECHO]1>a

CodePudding user response:

(echo(1)>a

or

(echo/1)>a

can be done.

An alternative is

>a=echo/1

because the =-sign is a token separator just like the SPACE (you may also use , or ; instead).

But regard, that

echo/1>a

cannot be used, because 1> is then taken as the redirection operator.


A completely different solution is to first assign a SPACE to a variable and then to use it:

rem // This assigns a single space character:
set "SPC= "
rem // A space before `>` would also be echoed out, hence use parenthesis:
(echo%SPC%1)>%SPC%a
rem // Alternatively, rearrange the command line:
>%SPC%a%SPC           
  •  Tags:  
  • Related