使用format-table在powershell输出结果时,是否可以仅对某些单词(而不是整行)进行着色。例如,此脚本递归扫描文件夹以查找字符串,然后使用format-table输出结果。
dir -r -i *.* | Select-String $args[0] |
format-table -Property @{label="Line #"; Expression={$_.LineNumber}; width=6},
Path, Line -wrap
希望能够用特定颜色格式化我们正在搜索的单词,这样你就可以清楚地看到它在行中的位置。
$index = $line.IndexOf($word, [System.StringComparison]::InvariantCultureIgnoreCase)
- EtienneT