import glob


def get_file(pattern):
    """Get filename from a shell expression.

    pattern : str, unix-type pattern for the file to search.

    Returns a single file or None if not found.
    If more than one file found, prints a warning, and returns first file.
    """
    files = glob.glob(pattern)
    if len(files) == 0:
        return None
    elif len(files) == 1:
        return files[0]
    else:
        print("WARNING: more than 1 file names matched the pattern. Return first")
        print("All matches: ",files)
        return files[0]