linux & unix shells can process subcommands like this.
$> command `subcommand`
does windows cmd shell similar feature?
You can get something similar using a variation of the for
command:
FOR /F "usebackq tokens=*" %%a IN (`subcommand`) DO @command %%a
One big difference (besides being unintuitive and much uglier) is that it'll execute command
once for each line produced by subcommand
Note that inside a script file, the percent signs must be doubled up (use non-doubled percent signs if you have some reason to want to do this at the command line).
As a whole, no. The Windows Command Prompt really isn't much of a shell in that it doesn't provide much functionality of its own, independent from the commands that you can run. For example, in most Un*x shells, file globbing (matching foo.*
to a list of files) is handled by the shell itself. In Windows, every application sees the foo.*
from the command line and has to implement the file globbing on its own.
If you're moving down the road of trying to automate Windows, or want a more full-featured shell, you should consider using PowerShell, which does let you do sub-commands:
command (subcommand)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With