sg_rs
sg_rs

Reputation: 491

How to pull data from gcp pubsub with the command line?

I know the command

gcloud pubsub subscriptions pull mySubscription --auto-ack

This command delivers a table with many other data. I want just the data.

enter image description here

Upvotes: 2

Views: 1277

Answers (2)

ralbuh
ralbuh

Reputation: 31

we can even skip the pipe into base64 like this

gcloud pubsub subscriptions pull mySubscription --format=json | jq -r '.[].message.data | @base64d'

Upvotes: 3

guillaume blaquiere
guillaume blaquiere

Reputation: 75810

you can ask the message as JSON and then process it as JSON with JQ. But the content is Base64 encoded, so decode it.

The full line to do that

gcloud pubsub subscriptions pull mySubscription --format=json | jq -r .[].message.data | base64 -d

Upvotes: 4

Related Questions