PowerShell tips and tricks part #4: automatic variables

This is translation of my article about some PowerShell tips & tricks not only for developers. I will split the article into more parts, so you won't get tired too early ;)

Operators and variables – Variables $$, $^

$$ and $^ are automatic variables that can be useful when using shell interactively. You will need it only rarely, but it could be worth knowing it. What's all that about can be seen in an example:

[0] Get-ChildItem -rec c:\temp\powershelltest\version1
... some files
[1] $^
Get-ChildItem
[2] $$
c:\temp\powershelltest\version1

The variables contain first and last token from the previous row. More accurately: Contains the first token in the last line received by the session and Contains the last token in the last line received by the session.
They can save your time when typing long paths passed to Get-ChildItem, Get-Item etc.

Have a look at StackOverflow that will prove that some people really use it.

Meta: 2010-05-14, Pepa