A sample array I have like below;
OVGARR=(ACCS ELB NOVOVG SCN MISOVG)
The position of the strings with *OVG can be in any index and there are more than different types of OVG strings. I want to get the value of the 1st *OVG string on the array, cut the "OVG" part of the string and assign it to a variable.
My initial solution is like below;
OV=`printf '%s\n' "${OVGARR[@]}" | grep -P 'OVG$' | head -1 | awk -F'OVG' '{print $1}'`
Though it works, is there a shorter and more efficient approach to what I would like to do?