How to filter data through awk or grep to get the time only?
curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/compute/tagsList?
api-version=2019-06-04"|
Through the above command I'm getting out put like below
root@puppetagent-ubuntu1:/home/azureuser# grep -i "shutdown_time" test.txt |awk '/value/{print}' |jq
[ { "name": "Application_Name", "value": "POC-Exception" }, { "name": "Cost_Center", "value": "1000501541" }, { "name": "Stage", "value": "POC" }, { "name": "shutdown_time", "value": "16:00 [IST]" } ]
So I want to filter where time and time zones are like IST or PST in value but in this where time is not fixed and time zone is not fixed. Please help me.
Use jq
:
$ ... | jq -r '.[]|select(.name == "shutdown_time").value'
16:00 [IST]
$ ... | jq -r '.[]|select(.name == "shutdown_time").value' | cut -d' ' -f1
16:00