https://gist.github.com/ignatenkobrain/53a64e30bdaadec34e0a#file-gistfile1-sh...
_dnf_help_command()
{
if perl -e "exit 0 if (successful); exit 1"; then
eval "$2='$( dnf help $1 | perl -ne "next unless /^$1/; s|.*?\[(.*?)\].*|\1|g; s/\|/ /g; print; exit" )'"
else
eval "$2='$( dnf help $1 | grep -E "^$1" | sed -e "s/|/ /g" -e "s/^$1 \[//g" -e "s/\].*$//g" )'"
fi
}
asd="group" && echo -e "abc\n$asd [one two three] [GRP]" | grep -E "^$asd" | sed -e "s/^$asd \[\(.*\)\].*$/\1/g"
С перлом все ок, там юзал "?" для нежадного поиска.