查询多个值

时间:2017-11-07 16:59:42

标签: aws-cli jmespath

我正在尝试按多个值进行过滤,但是我似乎无法使用和子句(例如filter1和filter 2等):

显示数据库名称为'testing'的快照

aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBInstanceIdentifier==`testing`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[
    {
        "SNAPSHOT": "test1",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test2",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test3",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test4",
        "DBNAME": "testing"
    }
]

显示名为'test1'的快照

$ aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBSnapshotIdentifier==`test1`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[
    {
        "SNAPSHOT": "test1",
        "DBNAME": "testing"
    },
        {
        "SNAPSHOT": "test1",
        "DBNAME": "testing2"
    }
]

显示名为test1

的数据库测试中的快照

aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBInstanceIdentifier==`testing`][?DBSnapshotIdentifier==`test1`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[]

如何实现这一目标?

1 个答案:

答案 0 :(得分:4)

你需要使用AND expression这样的事情才能成功

newDate=$(date +'%Y-%m-%d %T' --date="$givenDate - 10 minutes")
echo $newDate