2012-04-20 2 views
0

私のPowerShellスクリプトでは、gitのようなツールの出力を使用したいと思います。Powershellパイプラインのコマンドラインツールのコンソール出力を使用

 
git status | $_.Contains("nothing to commit") 

しかし、私はエラーを取得する:

はたとえば、コマンドラインが

 
git status 

戻り

 
# On branch master 
nothing to commit (working directory clean) 

は、今私は、次のパイプラインコマンドでこの出力を使用してみました

Expressions are only allowed as the first element of a pipeline.

私は間違っていますか?

答えて

2
$msg = [string](git status) | where { $_.Contains("nothing to commit") } 
2

あなたはselect-stringを使用することができます。

git status | select-string "nothing to commit" 
関連する問題