Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 538

Case-insensitive check in `jq` for equality

$
0
0

I found the following on the govc govmomi github pages, which allows me to search for VMs by MAC address:

govc object.collect -json -type m / config.hardware.device \  | jq -r '      .      | select(.ChangeSet[].Val.VirtualDevice[].MacAddress == "00:50:56:bc:5e:3c")      | [.Obj.Type, .Obj.Value]      | join(":")' \  | xargs govc ls -L

Please find attached a snippet of govc output that should suffice:

{"Obj": {"Type": "VirtualMachine","Value": "vm-666"  },"ChangeSet": [    {"Val": {"VirtualDevice": [          {          },          {"MacAddress": "00:50:56:bc:5e:3c"          }        ]      }    }  ]}

The problem I'm facing is that some MACs contain upper, some lower case letters, and I don't know ahead of time which machine uses which scheme.I can't figure out how to make the == case insensitive.

I have found answers here on stackoverflow that suggest using ascii_downcase as a filter, but I don't know how to apply that w/ the ==.

The syntax suggested at https://stackoverflow.com/a/62454688 gives me a sequence of explode input must be a string errors (1 per line of govc output).

In case this matters for this exercise: this is happening on Mac OS 15.1, jq is installed via brew, version is 1.7.1.


Viewing all articles
Browse latest Browse all 538

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>