LoginSignup
4
5

More than 5 years have passed since last update.

find + sed で正規表現を使ったファイル名の一括変換

Posted at

よく使うのだが、よく忘れるのでメモ。

__keyword__に変換前の文字列を、__replace_keyword__には、変換後の文字列を入力する。

find . -name "*__keyword__*" | sed 'p;s/__keyword__/__replace_keyword__/g' | xargs -n2 mv

実行する前にmvechoとかに変えて、mvに渡される引数を事前に確認しておくといいかも。

4
5
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
4
5