def star_grep(cluster, logdir, cmdline, *args):
    """Scan (not real grep) for string matches in stdout"""
    pattern = cmdline[6:].encode(cluster.defaults['character_encoding'])
    for host in cluster:
        job = cluster.last_result.get(host)
        if job:
            res = job.result
            for line_number, line in enumerate(res.stdout.split(b'\n'), 1):
                if pattern in line:
                    print('%s [%d]: %s' % (host, line_number, line.rstrip()
                        .decode(cluster.defaults['character_encoding'],
                        'replace')))
            for line_number, line in enumerate(res.stderr.split(b'\n'), 1):
                if pattern in line:
                    print('%s [%d/stderr]: %s' % (host, line_number, line.
                        rstrip().decode(cluster.defaults[
                        'character_encoding'], 'replace')))
