bash - get text from response of shell command -


i want write script automate repetitive task do.

i issue command:

heroku pgbackups:capture --expire 

and response

my_db_url (database_url) ----backup---> b677

i issue command capture number (b677 in above)

curl -o latest.dump `heroku pgbackups:url b677` 

how can parse text , place value next command?

it's matter of parsing output of first command , saving variable:

capnum=$(heroku pgbackups:capture --expire | grep -- "--->" | awk '{print $nf}') 

and execute,

curl -o latest.dump $(heroku pgbackups:url ${capnum}) 

alternatively, may say:

curl -o latest.dump $(heroku pgbackups:url $(heroku pgbackups:capture --expire | grep -- "--->" | awk '{print $nf}')) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -