簡體   English   中英

如何在 powershell 中僅獲取 output 命令的一行?

[英]How can I get only one line for output of command in powershell?

在 Linux 中,我將其用於 select 特定行:

ip a | sed -n '3p' | xargs

但我不知道如何在 Powershell 中做到這一點。

正如 Smorkster 提到的,powershell 在對象中工作。

您可以使用此處所示的點符號來訪問 object 的屬性,然后使用索引

(Get-NetIPAddress).ipaddress[3]

Powershell(幾乎完全)在對象中工作。 這樣您就可以使用索引來獲得某個值/輸出。 所以你可以做

( Get-NetIPAddress ).ToString()[3] 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM