PowerShell “Period” operator, what does it do?

后端 未结 3 943
太阳男子
太阳男子 2021-01-29 03:43

I\'ve been looking online for a specific answer to better help me understand how this works. In PHP we use the \" . \" to concatenate strings. However in powershell I see things

相关标签:
3条回答
  • 2021-01-29 04:03

    Powershell has very good help files included that can answer many questions.

    See:

    get-help about_operators
    

    and you will find that the dot is used as both a Property dereferencing operator and a scope operator, with explanations of the use of each.

    Can also see this under about_operators on TechNet

    0 讨论(0)
  • 2021-01-29 04:08

    It's the member access operator. $_ is a special variable (the loop variable in this case). Therefore, $_.extension accesses or invokes the property extension on $_.

    0 讨论(0)
  • 2021-01-29 04:20

    DIR command is similar to Get-ChildItem command. The | is similar to foreach statement. The $_ sign indicates each element in foreach loop. In your case, the code should get all which have .txt extension from some location and then rename each of those elements due to { $_.name –replace “.“,”-” } rule

    0 讨论(0)
提交回复
热议问题