I have two questions. I know the $() is documented as a subexpression, but what about the double parenthesis without the $ ? I can't find its documentation in the about_operators page.
Also I know this is a stupid question, but there are dozens of books on powershell. Are there any on cmd itself. I know that powershell basically abrogates cmd, but I can't believe all those years there was not a book you could pick up to learn the windows command line.
There are a couple of differences between $() and ():
The subexpression operator $() can contain any number of statements. The expression inside parentheses () can only be a single pipeline
$() can be used to embed expression inside a double-quoted string; parentheses are just treated as literal characters in that context.
You'll mostly see $() used in the second case, to embed the result of some expression within a string, without the need for a temporary variable. Parentheses are mostly used either for changing the order of operations in an expression (causing the contents of the parentheses to be evaluated first), or to force PowerShell into expression parsing mode instead of argument parsing mode. (This is covered in the about_Parsing help file.)
As far as learning the old command prompt goes, a lot of that knowledge will depend on console applications (each with their own help files and syntax.) However, for the shell itself, I've always found this site to be a good reference: http://www.robvanderwoude.com/batchfiles.php
The topic ‘() and books on cmd’ is closed to new replies.