在命令周围加上花括号,Powershell会将包含的内容作为一个ScriptBlock对象。
~~~powershell
PS D:\Projects\htk\asr> {ping 127.0.0.1} | gm
TypeName:System.Management.Automation.ScriptBlock
Name MemberType Definition
---- ---------- ----------
CheckRestrictedLanguage Method void CheckRestrictedLanguage(System.Collections.Generic.IEnumer...
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetNewClosure Method scriptblock GetNewClosure()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationIn...
GetPowerShell Method powershell GetPowerShell(Params System.Object[] args), powershe...
GetSteppablePipeline Method System.Management.Automation.SteppablePipeline GetSteppablePipe...
GetType Method type GetType()
Invoke Method System.Collections.ObjectModel.Collection[psobject] Invoke(Para...
InvokeReturnAsIs Method System.Object InvokeReturnAsIs(Params System.Object[] args)
InvokeWithContext Method System.Collections.ObjectModel.Collection[psobject] InvokeWithC...
ToString Method string ToString()
Ast Property System.Management.Automation.Language.Ast Ast {get;}
Attributes Property System.Collections.Generic.List[System.Attribute] Attributes {g...
DebuggerHidden Property bool DebuggerHidden {get;set;}
File Property string File {get;}
Id Property guid Id {get;}
IsConfiguration Property bool IsConfiguration {get;set;}
IsFilter Property bool IsFilter {get;set;}
Module Property psmoduleinfo Module {get;}
StartPosition Property System.Management.Automation.PSToken StartPosition {get;}
~~~
ScriptBlock对象默认不会执行,只是原样输出文本,如下所示
~~~powershell
PS D:\Projects\htk\asr> ping 127.0.0.1
正在 Ping 127.0.0.1 具有 32 字节的数据:
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
127.0.0.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
PS D:\Projects\htk\asr> {ping 127.0.0.1}
ping 127.0.0.1
~~~
但是我们可以通过调用操作符`&`来执行ScriptBlock的内容,ScriptBlock中的命令会被逐行执行。
~~~powershell
PS D:\Projects\htk\asr> & {ping 127.0.0.1}
正在 Ping 127.0.0.1 具有 32 字节的数据:
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
来自 127.0.0.1 的回复: 字节=32 时间<1ms TTL=128
127.0.0.1 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
~~~
- Linux
- bash常见的命令汇总
- 切换用户登陆到bash时的目录
- grep匹配tab
- gperftools的使用
- Hyper-V安装Linux
- ubuntu on windows 忘记密码怎么办
- 修改用户默认shell
- ubuntu 安装pip
- Arch Linux安装记录
- Hyper-V中安装Linux的一些问题
- ASR
- 数据集
- PCM音频文件
- One-Pass算法
- CHiME5环境配置中遇到的一些问题
- Python
- 命令行参数解析
- 三目运算符
- Numpy
- 练习1
- 练习2
- Others
- GNU make 的用法
- pandoc
- Git
- PowerShell
- 花括号的作用
- 一条命令在多行内输入
- Tex
- Latex基础知识
- tikz库
- CTex使用中的一些问题
- C++
- 标准库list
- 数据结构
- kdtree
