title: Bash command for setting aws command output to a variable
body: <p>I want to assign a variable in shell script for the below aws command..
  If the command is successful,I want to assign the output to S3_BUCKET_REGION.Eg: S3_BUCKET_REGION = us-east-1.</p>
  
  <pre><code>S3_BUCKET_REGION=$( aws s3api get-bucket-location --bucket ${TF_STATE_S3_BUCKET} | jq -r '.LocationConstraint // "us-east-1"' )
  </code></pre>
  
  <p>But if the bucket does not exist,the error for the above command is "An error occurred (NoSuchBucket) when calling the GetBucketLocation operation: The specified bucket does not exist"</p>
  
  <p>I want to capture this error and echo it in the script.</p>
  
  <p>So if the command runs successfully,I want to assign to a variable.If not ,I want to echo the error.How to do conditional statement for this?</p>