-2

I am learning how to use google cloud I used this command:

"gsutil ls -la gs://bucket01/*"

And I get the follow information:

display.json#01
display.json#02
display.json#03
display.json#04
display.json#05

How can I delete all the previous version and just to keep the new file that would be display.json05?

jterrace
  • 64,866
  • 22
  • 157
  • 202
  • you are mixing two unrelated things together here it is unclear what you are trying to do as svn has nothing to do with gsutil in the context you are using –  May 02 '17 at 19:53
  • @JarrodRoberson - OP was not talking about SVN. I edited the question to replace "subversion" with "old versions", which is what he meant. – jterrace May 04 '17 at 17:50

1 Answers1

1

There is no wildcard that supports deleting all non-live versions, so you would need to delete them individually, like so:

gsutil -m rm gs://bucket01/display.json#01 gs://bucket01/display.json#02 gs://bucket01/display.json#03 gs://bucket01/display.json#04

Depending on your use case, you may just wish to turn versioning off, or configure an Object Lifecycle Management rule on your bucket with Age and NumNewerVersions conditions.

Travis Hobrla
  • 5,411
  • 23
  • 22