def append(filename, text, use_sudo=False, partial=False, escape=True,
    shell=False):
    func = use_sudo and sudo or run
    # Normalize non-list input to be a list
    if isinstance(text, basestring):
        text = [text]
    for line in text:
        regex = '^' + _escape_for_regex(line)  + ('' if partial else '$')
        if (exists(filename, use_sudo=use_sudo) and line
            and contains(filename, regex, use_sudo=use_sudo, escape=False,
                         shell=shell)):
            continue
        line = line.replace("'", r"'\\''") if escape else line
        func("echo '%s' >> %s" % (line, _expand_path(filename)))
Append string (or list of strings) ``text`` to ``filename``.
dataset/ETHPy150Open fabric/fabric/fabric/contrib/files.py/append