LoginSignup
0
0

More than 1 year has passed since last update.

AWS CLIでS3上の全メンバーのjsonを削除するコマンドが欲しい時()

Last updated at Posted at 2022-05-18

VSCodeで正規表現の置換ってついつい忘れがちなのでメモ
※ショートカットはMacの場合です、ご了承ください

量産したいコマンド

M000」の部分を変えたい

command.txt
aws s3 rm s3://example-environment/M000/json/detail.json

代入したい文字列

連番のように見えて実はところどころ歯抜け(悲しい過去が透けて見える…)

members.txt
M001
M002
M004
M005
M006
M008
M009
M010
M011
M012
M013
M014
M015

コマンド量産手順

  • VSCodeでmembers.txtを開く
  • 検索と置換ウィンドウを開く。ショートカットは⌘ + F
  • 右側の.*のアイコンをクリック
  • 上の欄に入力して検索
    ※文字列を()で囲むのがポイント
上の欄.txt
(M[0-9]{3})
  • 下の欄(表示されていない場合、入力欄左側の>をクリックして表示する)に置換後の文字列を入力
    $1でマッチした文字列をそのまま使用できる
下の欄.txt
aws s3 rm s3://example-environment/$1/json/detail.json

実行

  • 入力欄右側のReplace allアイコンをクリック
  • またはドキュメント内の任意の箇所にカーソルを移動して⌘+option+Enter
  • または下の欄にカーソルをフォーカスして⌘+Enterで実行

感想

連番のようで歯抜けな一連の番号が割り振られているので一行ずつ書くのが一番安心

0
0
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
0
0