Group Commands in Command Prompt
In command prompt it is possible to create a group of commands from the command line (not a batch file). This is useful for, among other things, copy&pasting scripts for testing without saving. To do this, just type "(" and hit enter, enter each command one by one (or paste a previously copied list of commands), then type ")" and hit enter.
Output for every command may also be redirected at the end of the block, in the same manner as Tip 7 on the Clever Tricks page: ") > log.txt" instead of just ")"
C:\>(
More? echo This is the first command
More? echo This is the second command
More? )
This is the first command
This is the second command
C:\>
To log the result of several commands, a commonly used method is
command1 > log.txt
command2 >> log.txt
command3 >> log.txt
But grouping can be used to simplify the code:
(
command1
command2
command3
) > log.txt
No comments:
Post a Comment