Reputation: 2088
There are countless examples about how to get tail for file content, but there is no for pipes.
Is there any way to get last line from pipe ?
I have long chain of piped commands and I want last 1 line only.
Upvotes: 1
Views: 440
Reputation: 3606
If you want the last object, that is send through the pipe, Select-Object
can do that for you:
$input | Select-Object -Last 1
If you are only interested in one particular property of this object, you can expand this property in the same statement:
[pscustomobject]@{propname = 'foo'},[pscustomobject]@{propname = 'bar'} |
Select-Object -Last 1 -ExpandProperty propname
Upvotes: 2