perform command substitution in MS-DOS

Posted by wiggin200 on Super User See other posts from Super User or by wiggin200
Published on 2012-10-31T13:40:36Z Indexed on 2012/10/31 17:03 UTC
Read the original article Hit count: 169

Filed under:

I wonder how you can make in MS-DOS a command substitution

Command substitution is a very powerful concept of the UNIX shell. It is used to insert the output of one command into a second command. E.g. with an assignment:

$ today=$(date) # starts the "date" command, captures its output
$ echo "$today"
Mon Jul 26 13:16:02 MEST 2004

This can also be used with other commands besides assignments:

$ echo "Today is $(date +%A), it's $(date +%H:%M)"
Today is Monday, it's 13:21

This calls the date command two times, the first time to print the week-day, the second time for the current time.

I need to know to do that in MS-DOS, (I already know that there is a way to perform something like that using as part of the for command, but this way is much more obfuscated and convoluted

© Super User or respective owner

Related posts about ms-dos