我有一个包含多个单词的文件。我只想得到那些包含我作为参数传递给程序的字母的单词。
例如:test.txt
apple
car
computer
tree
./select.ps1 test.txt oer
结果应该是这样的:
computer
我写了这个:
foreach ( $line in $args[0] ) {
Get-Content $line | Select-String -Pattern $args[1] | Select-String -Pattern $args[2] | Select-String $args[3]
}
但是如果我想使用例如 10 个参数并且不想一直更改我的代码怎么办?我将如何管理?