Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell`echo-e";1\n2\n3“|tail-n1`等效物_Powershell - Fatal编程技术网

Powershell`echo-e";1\n2\n3“|tail-n1`等效物

Powershell`echo-e";1\n2\n3“|tail-n1`等效物,powershell,Powershell,关于如何获取文件内容的尾部,有无数的例子,但对于管道,则没有 有没有办法把最后一根线从管子里拿出来 我有一长串管道命令,我只需要最后一行 如果需要最后一个对象,即通过管道发送的对象,Select object可以为您执行以下操作: $input |选择对象-最后一个1 如果您只对此对象的一个特定属性感兴趣,则可以在同一语句中展开此属性: [pscustomobject]@{propname='foo'},[pscustomobject]@{propname='bar'} 选择对象-最后一个1-

关于如何获取文件内容的尾部,有无数的例子,但对于管道,则没有

有没有办法把最后一根线从管子里拿出来


我有一长串管道命令,我只需要最后一行

如果需要最后一个对象,即通过管道发送的对象,
Select object
可以为您执行以下操作:

$input |选择对象-最后一个1
如果您只对此对象的一个特定属性感兴趣,则可以在同一语句中展开此属性:

[pscustomobject]@{propname='foo'},[pscustomobject]@{propname='bar'}
选择对象-最后一个1-ExpandProperty propname

或-1是数组的最后一个元素

(echo 1 2 3)[-1]

3

你是说通过管道发送的最后一个对象吗
$input | Select Object-Last 1
就是这样做的。这似乎在@ManuelBatsching工作,但缺少一件事-
| Select-ExpandProperty propname
,谢谢:)我想你的意思是
echo-e“1\n2\n3”