I have an array that is being stored in a bash variable that is a json array of dates (it's currently being produced by a separate script). It looks like the following
["2019-09-19 03:13:29", "2019-09-19 20:20:18", "2019-09-19 18:19:50", "2019-09-19 06:07:17", "2019-09-19 11:53:25"]
I want to iterate over these dates and preserve the white space in the dates so I can use them with the gdate
command. I'm currently using jq
but that is splitting up the date part from the time part. i.e.
dates=$(python date_producing_script.py | jq -c -r '.[]')
for date in ${dates[@]}; do
echo $date
#end goal is to do something here w/ gdate ex gdate -d $date ...
done
However this gives something like
2019-09-19
03:13:29
2019-09-19
20:20:18
2019-09-19
18:19:50
2019-09-19
06:07:17
2019-09-19
11:53:25
Where I'm looking for something like the following
2019-09-19 03:13:29
2019-09-19 20:20:18
2019-09-19 18:19:50
2019-09-19 06:07:17
2019-09-19 11:53:25
(one confusing thing for me here is that if I just do the python date_producing_script.py | jq -c -r '.[]'
command in a terminal it looks the way I want it to)
However ideally I would want something like. Is there anyway to get this result from the input in shell script