() and books on cmd

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 2 years, 1 month ago.

  • Author
    Posts
  • #19847
    Profile photo of Garegin Asatryan
    Garegin Asatryan
    Participant

    Hello

    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.

  • #19848
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    There are a couple of differences between $() and ():

    [ul]
    [li]The subexpression operator $() can contain any number of statements. The expression inside parentheses () can only be a single pipeline[/li]
    [li]$() can be used to embed expression inside a double-quoted string; parentheses are just treated as literal characters in that context.[/li]
    [/ul]

    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.)

  • #19849
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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

You must be logged in to reply to this topic.