【发布时间】:2020-12-12 08:39:18
【问题描述】:
在 Linux 中,我使用它来选择特定的行:
ip a | sed -n '3p' | xargs
但我不知道如何在 Powershell 中制作它。
【问题讨论】:
-
在Powershell中无法轻松获取广播地址
标签: linux powershell command-line
在 Linux 中,我使用它来选择特定的行:
ip a | sed -n '3p' | xargs
但我不知道如何在 Powershell 中制作它。
【问题讨论】:
标签: linux powershell command-line
正如 Smorkster 提到的,powershell 在对象中工作。
您可以使用此处所示的点符号来访问对象的属性,然后使用索引
(Get-NetIPAddress).ipaddress[3]
【讨论】:
Test-NetConnection -InformationLevel "Quiet" 8.8.8.8 -p 81 -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
Powershell(几乎完全)在对象中工作。这样您就可以使用索引来获得某个值/输出。 所以你可以做
( Get-NetIPAddress ).ToString()[3]
【讨论】:
( Get-NetIPAddress ).ToString()[3] 只给出一个字母t