LinuxCommandLibrary

tea

Install and manage software packages

TLDR

Log into a Gitea server

$ tea login add --name "[name]" --url "[url]" --token "[token]"
copy

Display all repositories
$ tea repos ls
copy

Display a list of issues
$ tea issues ls
copy

Display a list of issues for a specific repository
$ tea issues ls --repo "[repository]"
copy

Create a new issue
$ tea issues create --title "[title]" --body "[body]"
copy

Display a list of open pull requests
$ tea pulls ls
copy

Open the current repository in a browser
$ tea open
copy

SYNOPSIS

tee [OPTION]... [FILE]...

PARAMETERS

-a, --append
    Append to the given FILEs, rather than overwriting them. This is crucial for maintaining logs or accumulating data over multiple runs.

-i, --ignore-interrupts
    Ignore interrupt signals (like Ctrl-C). This allows tee to continue processing even if an interrupt signal is received, useful for critical operations.

-u, --unbuffered
    Unbuffer output. By default, tee buffers its output, writing in blocks. This option forces tee to write to each output FILE as soon as data is received, useful for real-time monitoring of streams.

--output-error[=MODE]
    Set behavior on write errors. MODE can be warn-errno (default: diagnose errors with errno message), warn-once (diagnose errors just once), warn-all (diagnose errors for all attempts), or exit (exit on first write error).

DESCRIPTION

The tee command reads standard input and writes it to both standard output and one or more specified files. This dual output capability makes it invaluable in command pipelines, allowing users to simultaneously view intermediate output on the console while saving it to a file for later analysis, logging, or further processing.

By default, tee will overwrite any existing files it writes to. However, it provides an option to append to files, preserving their previous content. It acts like a "T" junction in a pipe, splitting the data stream. Commonly used with other powerful commands like grep, sort, awk, or sed, tee enables non-destructive data flow monitoring and persistence. For instance, command | tee log.txt displays the command's output and saves it to log.txt. For continuous logging without overwriting, long_process | tee -a log.txt is often employed. Its simplicity, combined with its profound utility, establishes tee as a fundamental tool in Unix-like operating systems for scripting and efficient command-line operations.

CAVEATS

By default, tee overwrites target files. Always use -a for appending if you intend to preserve existing content.
If not used with -u, tee might buffer output, leading to delays in real-time display or logging, especially in pipelines. Error handling for multiple files: by default, tee attempts to continue processing even if writing to one file fails, unless --output-error=exit is specified.

COMMON USE CASES

Logging and Monitoring: Capturing the output of a command (e.g., a long-running script, a build process) to a log file while simultaneously displaying it on the console for real-time monitoring.
Pipeline Debugging: Saving the intermediate output of a complex command pipeline to a file for later inspection and debugging, without interrupting the flow of the pipeline.
Data Persistence: When you want to save the results of a command to a file for future use, but also need to pass those same results to the next command in a pipeline.

HISTORY

The tee command is a standard utility that has been a part of Unix-like operating systems for many decades, pre-dating GNU Core Utilities. Its core functionality of duplicating a stream to both standard output and files has remained consistent due to its fundamental utility. Modern implementations, such as those in GNU Core Utilities, have added more advanced error handling options like --output-error to enhance its robustness and control over its behavior in complex scenarios, but its basic 'T-junction' purpose is historical.

SEE ALSO

cat(1), less(1), more(1), mkfifo(1), script(1)

Copied to clipboard