i have to run the following command within a script in bash and store its output in a variable. the db_name is another variable that i want to substitute too. Notice the name-db and true, i don't want my shell to start running them.
aws rds describe-db-snapshots --db-instance-identifier ${db_name} --query 'DBSnapshots[?contains(DBSnapshotIdentifier, `name-db`) == `true`]'.DBSnapshotIdentifier --output text | sort -k8 | tail -n1 | gawk '{print $4}'
I started by storing the whole command in a string and then run the string using eval or the string directly but it fails everytime. I guess it keeps expanding the true and the name-db bit. Any help ?
resp=$( aws ..... ); echo $resp? This will actually open a sub-shell andrespwill contain the output. Edit: this is kinda the same as the answer from @ruakh.