Skip to content

Instantly share code, notes, and snippets.

@MutatedBread
Last active April 7, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MutatedBread/a25a3df6816d64c9276a3193856c8b9d to your computer and use it in GitHub Desktop.
Save MutatedBread/a25a3df6816d64c9276a3193856c8b9d to your computer and use it in GitHub Desktop.
Some useful gsutil commands

Some useful gsutil Commands

Make bucket

gsutil mb gs://new_bucket/

Upload

Upload a single file

gsutil cp dir/file gs://your_bucket

Copy entire folder into bucket directory

gsutil cp dir/* gs://your_bucket/dir

Copy files with specific extensions into bucket directory

gsutil cp dir/*.json gs:://your_bucket/dir

Copy entire directory into bucket

gsutil cp -r special_dir gs://your_bucket

The folder uploaded will exist in gs://your_bucket/special_dir with all files in it.

Upload bulk items in concurrent manner (better, need faster internet)

gsutil -m cp ...

Delete

Delete one file

gsutil rm gs://your_bucket/some.json

Delete all files in a directory

gsutil rm gs://your_bucket/dir

Delete everything

gsutil rm gs://your_bucket/**

Delete concurrently (faster, need faster internet)

gsutil -m rm ...

Delete bucket

gsutil rm -r gs://your_bucket/

List

Buckets

gsutil ls

Bucket content

gsutil ls gs://your_bucket/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment