-1

I could delete the 3 files(objects), "apple.jpg", "orange.png" and "kiwi.gif" on GCS with the "gsutil" command below on Cloud Shell:

(Hint: gs://<Bucket_Name>/<File_Name>)

gsutil rm gs://test.com/apple.jpg gs://test.com/orange.png gs://test.com/kiwi.gif

Now, I want to delete the 3 same files, "apple.jpg", "orange.png" and "kiwi.gif" with "fruits.txt" file which lists the 3 same files:

fruits.txt:

gs://test.com/apple.jpg
gs://test.com/orange.png
gs://test.com/kiwi.gif

However, I don't know what command with "gsutil" to run to delete them with "fruits.txt" file. What command should I run?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

2 Answers2

4

This command with "gsutil" works to delete the 3 same files with "fruits.txt" file:

cat fruits.txt | gsutil -m rm -I

Actually, there is a hint on Google Cloud Documentation for GCS(Google Cloud Storage) with "gsutil":

enter image description here

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
2

This can be done using Linux based shell commands. I tested the following and it worked:

gsutil rm $(cat fruits.txt)

The $(cat fruits.txt) using Linux shell to take the content of the file fruits.txt and supply that as parameters to the gsutil command.

See also:

Kolban
  • 13,794
  • 3
  • 38
  • 60