perform command substitution in MS-DOS
- by wiggin200
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