Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using grep to remove specific objects in GCS with gsutil -rm

I have a bucket with many objects, and I can successfully use grep to take the specific objects and output them into a text file. I want to use gsutil -rm and read the text file line by line and remove the corresponding object in gcs, but how can I go about doing this?

Or is there a way to directly remove objects from GCS using gsutil -rm and grep? Thanks!

like image 257
user3390790 Avatar asked Feb 09 '26 19:02

user3390790


1 Answers

Assuming you output the list of objects to remove to the file remove.txt, you could use this command to remove the named objects:

gsutil -m rm -I < remove.txt

like image 176
Mike Schwartz Avatar answered Feb 12 '26 15:02

Mike Schwartz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!