My bash script is like :
vol_id=("ocid1.volume.oc1" "ocid1.volume.oc1.iad")
vol1=("volume1" "volume2")
for vol2 in "${vol1[@]}"
do
echo $vol2
for vol_nm in "${vol_id[@]}"
do
oci bv backup list -c ocid1.compartment.oc1--volume-id $vol_nm --limit 1 --sort-by TIMECREATED > a.txt
dt=`grep -i time-created a.txt | tr -s ' ' | cut -d ':' -f2|cut -d '"' -f2`
h=`grep -i time-created a.txt | tr -s ' ' | cut -d ':' -f3`
m=`grep -i time-created a.txt | tr -s ' ' | cut -d ':' -f4|cut -d '.' -f1`
bkp_date="$dt:$h:$m"
echo $bkp_date
done
done
This script will find latest backup date for each volume id sent in vol_id array. I want output like :
Volume1 2018-07-09T05:45:45
Volume2 2018-07-09T05:11:16
But i am getting:
Volume1
2018-07-09T05:45:45
2018-07-09T05:11:16
Volume2
2018-07-09T05:45:45
2018-07-09T05:11:16