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
Post a Comment