0

The following command works just fine in bash:

aws ec2 describe-instances \
  --filters "Name=tag:Name,Values=XXXXXXX" "Name=instance-state-code,Values=16" \
  --query 'Reservations[0].Instances[0].PublicDnsName'

However, if I try to run it in zsh, it gives me:

(eval):1: no matches found: Reservations[0].Instances[0].PublicDnsName

Is there any way of working this around?

I'm running:

aws-cli/1.11.5 Python/2.7.6 Linux/4.4.0-45-generic botocore/1.4.62
1
  • Use double quotes around the query instead of single? Commented Oct 21, 2016 at 0:24

1 Answer 1

2

Try this:

aws ec2 describe-instances \
  --filters "Name=tag:Name,Values=XXXXXXX" "Name=instance-state-code,Values=16" \
  --query '"Reservations[0].Instances[0].PublicDnsName"'

Brackets are a used for globbing in both zsh and bash. The difference is that by default bash leaves a pattern unchanged, if it does not match, while zsh prints a "no match found"-message.

Usually quoting them with single quotes - as done in question - should solve this issue. But it seems that at least the value of the option --query is run through eval without prior sanitation or extra quoting. You get the error message as the existing single quotes are not passed on as part of the value. In the solution I suggesed, the double quotes will be passed on, so that the query is still quoted when it is run through eval.

1
  • Double quotes was the only way to get --query working on Windows as well. Thanks.
    – naaman
    Commented May 17, 2019 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .