手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Windows Powershell 管道和重定向
Windows Powershell 管道和重定向
摘要:管道把上一条命令的输出作为下一条命令的输入。PowerShell管道例如通过ls获取当前目录的所有文件信息,然后通过Sort-Descend...

管道

把上一条命令的输出作为下一条命令的输入。

Windows Powershell 管道和重定向1

PowerShell管道

例如通过ls获取当前目录的所有文件信息,然后通过Sort -Descending对文件信息按照Name降序排列,最后将排序好的文件的Name和Mode格式化成Table输出。

PS C:PStest> ls | sort -Descending Name | Format-Table Name,Mode Name Mode ---- ---- d.txt -a--- c.txt -a--- b.txt -a--- ABC d---- a.txt -a---

重定向

把命令的输出保存到文件中,‘>'为覆盖,'>>'追加。

PS C:PStest> "Powershell Routing" >test.txt PS C:PStest> Get-Content .test.txt Powershell Routing PS C:PStest> "Powershell Routing" >>test.txt PS C:PStest> "Powershell Routing" >>test.txt PS C:PStest> "Powershell Routing" >>test.txt PS C:PStest> "Powershell Routing" >>test.txt PS C:PStest> "Powershell Routing" >>test.txt PS C:PStest> Get-Content .test.txt Powershell Routing Powershell Routing Powershell Routing Powershell Routing Powershell Routing Powershell Routing PS C:PStest>

【Windows Powershell 管道和重定向】相关文章:

Windows Powershell创建对象

PowerShell Contains函数查找字符串实例

浅谈PowerShell 捕获错误

PowerShell创建Byte数组例子

PowerShell中定义哈希散列(Hash)和调用例子

PowerShell入门教程之PowerShell管道介绍

PowerShell函数中接收管道参数实例

PowerShell函数指定返回值类型实例

Windows PowerShell 微软官方解释

PowerShell脚本开发之对指定IP进行端口扫描

精品推荐
分类导航