1
Powershell -Command "cat .\tmp.txt | %{$_ -replace '\D', ''}"
.batスクリプトのPowershellコマンドがうまく動作しないのはなぜですか?.batスクリプトからPowershellコマンドを実行すると機能しませんが、コマンドラインで直接入力すると機能します。
Expressions are only allowed as the first element of a pipeline.
At line:1 char:39
+ cat .\tmp.txt | {$_ -replace '\D', ''} <<<<
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline
いや、まだ同じエラー – Quak
DOSが解釈しようとしていたのは%でした。私の修正を参照してください。 – TechSpud
nice、ありがとうございます – Quak