Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows bat alternative for Bash inline command

Is there any Windows equivalent syntax to run a command within another command in a bat script file?

In Linux, you can simply use $(...) or ``.

like image 793
Mohsen Avatar asked Aug 13 '12 06:08

Mohsen


1 Answers

Yes, at least for simple things:

@setlocal enableextensions enabledelayedexpansion
@echo off
for /f %%w in ('echo xyzzy') do set var=%%w
echo Output is %var%
endlocal

The output of that script is:

Output is xyzzy

with the xyzzy coming from the echo command.

Running for /? from a command window should give you a more comprehensive list of options.

like image 158
paxdiablo Avatar answered Oct 20 '22 00:10

paxdiablo