Search code examples
google-cloud-platformgoogle-cloud-storagegsutil

Is there a way to grep through text documents stored in Google Cloud Storage?


Question

Is there a way to grep through the text documents stored in Google Cloud Storage?

Background

I am storing over 10 thousand documents (txt file) on a VM and is using up space. And before it reaches the limit I want to move the documents to an alternative location. Currently, I am considering to move to Google Cloud Storage on GCP.

Issues

I sometimes need to grep the documents with specific keywords. I was wondering if there is any way I can grep through the documents uploaded on Google Cloud Storage? I checked the gsutil docs, but it seems ls,cp,mv,rm is supported but I dont see grep.


Solution

  • Unfortunately, there is no such command like grep for gsutil.

    The only similary command is gsutil cat.

    I suggest you can create a small vm, and grep on the cloud will faster and cheaper.

    gsutil cat gs://bucket/ | grep "what you wnat to grep"