开发者

What does $$, $?, $^ represent in powershell?

Saw these variables in the debugger and I'm n开发者_Go百科ot sure what they do.


  • $_ The current pipeline object; used in script blocks, filters, the process clause of functions, where-object, foreach-object and switch
  • $^ contains the first token of the last line input into the shell
  • $$ contains the last token of last line input into the shell
  • $? Contains the success/fail status of the last statement

Source: http://www.computerperformance.co.uk/powershell/powershell_variables.htm#%24Dollar_variables_


Read

Get-Help About_Automatic_Variables

Its all about the goodness of automatic variables that get created when using PowerShell console.


In PowerShell, a dollar sign preceding a name indicates a variable. The symbols in question are just special cases of variables provided by the PowerShell environment. They are also known as "automatic" variables. More specifically:

  • $$ is a variable containing the last token of the last line input into the shell
    (does not contain the whole command)

  • $^ is a variable containing the first token of the last line input into the shell
    (does not contain the whole command)

  • $? is a variable containing the success or failure of the last statement
    (False if the previous command ended with an error; True otherwise.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜