Make it an array assignment, and then use the first element of the array (to hold with the "assuming only one match"):
foo=( /a/c*/d/ )
echo "PATH=${foo[0]}:$PATH" >>.env
By contrast, if you don't specifically want the assumption, you can use ${array[*]}
after setting :
as the first character in IFS
to expand correctly even in the case where there were multiple matches:
foo=( /a/c*/d/ )
IFS=:
echo "PATH=${foo[*]}:$PATH" >>.env
You could avoid needing to change IFS
or pay the efficiency cost of starting a subprocess by expanding the list of paths to a separate variable:
printf -v path_prefix '%s:' /a/c*/d/
echo "PATH=${path_prefix}$PATH" >>.env