LoginSignup
2
2

More than 5 years have passed since last update.

WindowsでGnuWin32のfindを使う際の -exec の指定方法

Posted at

WindowsでGnuWin32のfindを使っていて、該当ファイルに対して-execでコマンドを実行したい際の指定方法はこう。

find . -name "*.snap" -exec rm {} ";"

上記はカレントディレクトリ以下の ".snap" で終わるファイル名のファイルを削除するコマンドである。
{}は当該ファイル名に置換される。-execではコマンドの終了を;で指定する必要があるが、これはコマンドプロンプトでは特殊記号であるため、引用符で囲む必要がある。

なお、Linux系では\;とエスケープする方法が知られているがWindowsのコマンドプロンプトではこれは使えない。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2