Just as you would use the rm command to delete a file on your own system, the gsutil rm command can be used to remove files and directories within a bucket:
- Use the gsutil rm command as follows to delete file(s) from the bucket. The command is followed by the source URL of the file and an optional -r to indicate removal of internal subdirectories along with files in a folder:
gsutil rm gs://loonycorn-bucket-00/image1.png
- Do not forget to add a file extension properly or the file shall not be deleted. Later, you can use the ls command to verify your deletion.
- Similarly, the rb command deletes the whole bucket, along with the files inside it.