powershell - 如何在powershell格式表中显示行号或行号
问题描述
我希望格式表提供的数据包含项目的行号或行号。我怎样才能做到这一点?
一些命令 | 英尺
Line Something Else
---- --------- ----
0 Item1 Property1
1 Item2 Property2
解决方案
这是我的看法。我的一些 osx 进程没有作为普通用户的名称。
get-process | where name |
foreach { $line = 0 } { $line++; $_ } |
ft @{n='line';e={$line}}, name, id
line Name Id
---- ---- --
1 accountsd 368
2 AirPlayUIAgent 508
3 akd 2415
4 AMPDeviceDiscov 412
5 AppleSpell 1937
拿两个:
ps | where name | select -first 5 |
foreach { $line = 0 } { $_ | add-member -passthru line (++$line) } |
select line,name,id
line Name Id
---- ---- --
1 accountsd 368
2 AirPlayUIAgent 508
3 akd 2415
4 AMPDeviceDiscov 412
5 AppleSpell 1937
推荐阅读
- python - 使用 Sympy 获取单个向量基的标量
- spring-boot - hystrix中commandkey groupkey和threadpoolkey的区别
- javascript - 如何使用 Cannon.js + Three.js 进行对象跳转
- javascript - 如何使用 Node/Express 在控制器之间传输信息
- c++ - 无法分配任何大于 255 OpenCV 的值
- c++ - 在 C++ 中的另一个类中初始化一个类
- c++ - 这个 for 循环是如何工作的,为什么它总是输出相同的一组数字?
- string - 匹配 ArrayList 集合中的标题和布尔值
- oracle - 如何使用 owa_util.redirect_url 重定向到另一个 url?
- git - 无法与 40.74.28.9 端口 22 协商:找不到匹配的主机密钥类型。他们的提议:ssh-rsa