import fnmatch


def filter_group_names(groups, patterns):
    """Filter log groups by shell patterns.
    """
    group_names = [g['logGroupName'] for g in groups]
    matched = set()
    for p in patterns:
        matched.update(fnmatch.filter(group_names, p))
    return [g for g in groups if g['logGroupName'] in matched]