3

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!

3
  • 1
    Show sample input and your desired output for that sample input. Commented Aug 12, 2015 at 19:05
  • So let's say I have objects named hello.jar, hello2.jar, hello3.jar in a bucket. I'd want to do something like gsutil rm gs://my_buck | grep hello. Commented Aug 12, 2015 at 20:12
  • Please read stackoverflow.com/help/how-to-ask and rewrite your question Commented Aug 13, 2015 at 0:18

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I didn't see this as an option on the documentation for gsutil rm, but good to know =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.