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

Convert human readable time to epoch inline with jq for time comparison

$
0
0

I am writing a bash script to compare VM creation date to an epoch time gathered in a previous step to see what VMs were recreated before a certain date. These are bosh vms which gives human readable time. Example: Fri Jul 16 17:34:44 UTC 2024

To get a list of vm creation dates, my bosh command looks like this:

bosh is --vitals --json | jq -r '.Tables[].Rows[].vm_created_at'

What I need is something like this:

bosh is --vitals --json | jq -r '.Tables[].Rows[] | select( .vm_created_at(somehow convert to epoch) < $epoch_from_previous_step).instance_name'

I'm not sure if that is doable in that command. Or do I have to pull each one out and convert...tough to wrap my head around it. There's anywhere from 75 to 450 VMs in the foundations I am running this against, and I need to find the VMs recreated before an already captured epoch time stamp. Thanks!


Viewing all articles
Browse latest Browse all 657

Trending Articles



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