小编psg*_*g20的帖子

Powershell 自定义排序

我的 txt 文件中有以下内容,该文件将由 powershell 读取,并应根据自定义条件重新排列

文件:abc.txt

General
User1/Alert
User1/LogicApp
General/Abc
User2/Alert
User2/LogicApp
Run Code Online (Sandbox Code Playgroud)

上面应该按自定义条件排序,如果“General”存在,它应该位于列表顶部,如果字符串“LogicApp”存在,它应该位于 General 旁边。因此,输出应该类似于下面的内容

General
General/abc
User1/LogicApp
User2/LogicApp
User1/Alert
User2/Alert
Run Code Online (Sandbox Code Playgroud)

如果字符串“General”不存在,则字符串“LogicApp”应优先。我们可以在 Powershell 中进行这种自定义排序吗?

powershell powershell-4.0

2
推荐指数
1
解决办法
58
查看次数

标签 统计

powershell ×1

powershell-4.0 ×1