title: filter json via bash - case insensitive
body: <p>I have json code and need to filter it by the value of the attribute <em>DNSName</em>. The filter must be case insensitive.</p>
  
  <p>How can I do that? Is there a possibility to solve it with <em>jq</em>?</p>
  
  <p>This is how I create the json code:
  </p>
  
  <pre class="lang-bash prettyprint-override"><code>aws elbv2 describe-load-balancers --region=us-west-2 | jq
  </code></pre>
  
  <p>My unfiltered source json code looks like this:
  </p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "LoadBalancers": [
          {
              "IpAddressType": "ipv4", 
              "VpcId": "vpc-abcdabcd", 
              "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB1/a00000000000000a", 
              "State": {
                  "Code": "active"
              }, 
              "DNSName": "MY-LB1-123454321.us-west-2.elb.amazonaws.com", 
              "SecurityGroups": [
                  "sg-00100100", 
                  "sg-01001000", 
                  "sg-10010001"
              ], 
              "LoadBalancerName": "MY-LB1", 
              "CreatedTime": "2018-01-01T00:00:00.000Z", 
              "Scheme": "internet-facing", 
              "Type": "application", 
              "CanonicalHostedZoneId": "ZZZZZZZZZZZZZ", 
              "AvailabilityZones": [
                  {
                      "SubnetId": "subnet-17171717", 
                      "ZoneName": "us-west-2a"
                  }, 
                  {
                      "SubnetId": "subnet-27272727", 
                      "ZoneName": "us-west-2c"
                  }, 
                  {
                      "SubnetId": "subnet-37373737", 
                      "ZoneName": "us-west-2b"
                  }
              ]
          }, 
          {
              "IpAddressType": "ipv4", 
              "VpcId": "vpc-abcdabcd", 
              "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b", 
              "State": {
                  "Code": "active"
              }, 
              "DNSName": "MY-LB2-9876556789.us-west-2.elb.amazonaws.com", 
              "SecurityGroups": [
                  "sg-88818881"
              ], 
              "LoadBalancerName": "MY-LB2", 
              "CreatedTime": "2018-01-01T00:00:00.000Z", 
              "Scheme": "internet-facing", 
              "Type": "application", 
              "CanonicalHostedZoneId": "ZZZZZZZZZZZZZ", 
              "AvailabilityZones": [
                  {
                      "SubnetId": "subnet-54545454", 
                      "ZoneName": "us-west-2a"
                  }, 
                  {
                      "SubnetId": "subnet-64646464", 
                      "ZoneName": "us-west-2c"
                  }, 
                  {
                      "SubnetId": "subnet-74747474", 
                      "ZoneName": "us-west-2b"
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I now want some bash code to filter this result for the record with the DNSName property value <em>MY-LB2-9876556789.us-west-2.elb.amazonaws.com</em>, and need the entire LoadBalancer object back as a result. This is how I wish my result to look like:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "IpAddressType": "ipv4", 
      "VpcId": "vpc-abcdabcd", 
      "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:000000000000:loadbalancer/app/MY-LB2/b00000000000000b", 
      "State": {
          "Code": "active"
      }, 
      "DNSName": "MY-LB2-9876556789.us-west-2.elb.amazonaws.com", 
      "SecurityGroups": [
          "sg-88818881"
      ], 
      "LoadBalancerName": "MY-LB2", 
      "CreatedTime": "2018-01-01T00:00:00.000Z", 
      "Scheme": "internet-facing", 
      "Type": "application", 
      "CanonicalHostedZoneId": "ZZZZZZZZZZZZZ", 
      "AvailabilityZones": [
          {
              "SubnetId": "subnet-54545454", 
              "ZoneName": "us-west-2a"
          }, 
          {
              "SubnetId": "subnet-64646464", 
              "ZoneName": "us-west-2c"
          }, 
          {
              "SubnetId": "subnet-74747474", 
              "ZoneName": "us-west-2b"
          }
      ]
  }
  </code></pre>
  
  <p>Does anyone know how to do it?</p>
  
  <hr>
  
  <p>Update:
  This solution works, but is not case insensitive:</p>
  
  <pre class="lang-json prettyprint-override"><code>aws elbv2 describe-load-balancers --region=us-west-2 | jq -c '.LoadBalancers[] | select(.DNSName | contains("MY-LB2"))'
  </code></pre>
  
  <hr>
  
  <p>Update:
  This solution seems to work even better:</p>
  
  <pre class="lang-json prettyprint-override"><code>aws elbv2 describe-load-balancers --region=us-west-2 | jq -c '.LoadBalancers[] | select(.DNSName | match("my-lb2";"i"))'
  </code></pre>
  
  <p>But I did not have the chance to test in detail yet.</p>