xtee
is a versatile command-line utility handy in taking a single stream of input, from standard input, and splitting it into two outputs, standard output and file.
- Splits incoming standard input into standard output and file.
- Supports soaking up input before writing to output file.
- Supports appending and overwriting outputs.
- Supports deduplication.
- Cross-Platform (Windows, Linux & macOS).
Visit the releases page and find the appropriate archive for your operating system and architecture. Download the archive from your browser or copy its URL and retrieve it with wget
or curl
:
-
...with
wget
:wget https://github.com/hueristiq/xtee/releases/download/v<version>/xtee-<version>-linux-amd64.tar.gz
-
...or, with
curl
:curl -OL https://github.com/hueristiq/xtee/releases/download/v<version>/xtee-<version>-linux-amd64.tar.gz
...then, extract the binary:
tar xf xtee-<version>-linux-amd64.tar.gz
Tip
The above steps, download and extract, can be combined into a single step with this onliner
curl -sL https://github.com/hueristiq/xtee/releases/download/v<version>/xtee-<version>-linux-amd64.tar.gz | tar -xzv
Note
On Windows systems, you should be able to double-click the zip archive to extract the xtee
executable.
...move the xtee
binary to somewhere in your PATH
. For example, on GNU/Linux and OS X systems:
sudo mv xtee /usr/local/bin/
Note
Windows users can follow How to: Add Tool Locations to the PATH Environment Variable in order to add xtee
to their PATH
.
Before you install from source, you need to make sure that Go is installed on your system. You can install Go by following the official instructions for your operating system. For this, we will assume that Go is already installed.
go install -v github.com/hueristiq/xtee/cmd/xtee@latest
-
Clone the repository
git clone https://github.com/hueristiq/xtee.git
-
Build the utility
cd xtee/cmd/xtee && \ go build .
-
Move the
xtee
binary to somewhere in yourPATH
. For example, on GNU/Linux and OS X systems:sudo mv xtee /usr/local/bin/
Windows users can follow How to: Add Tool Locations to the PATH Environment Variable in order to add
xtee
to theirPATH
.
Caution
While the development version is a good way to take a peek at xtee
's latest features before they get released, be aware that it may have bugs. Officially released versions will generally be more stable.
To display help message for xtee
use the -h
flag:
xtee -h
help message:
_
__ _| |_ ___ ___
\ \/ / __/ _ \/ _ \
> <| || __/ __/
/_/\_\\__\___|\___|
v0.4.0
USAGE:
xtee [OPTION]... <FILE>
INPUT OPTIONS:
--soak bool soak up all input before writing to file
OUTPUT OPTIONS:
-u, --unique bool output unique lines
-a, --append bool append lines to output
-q, --quiet bool suppress output to stdout
-p, --preview bool preview new lines, without writing to file
pflag: help requested
-
Appending Unique Lines to File
➜ cat stuff.txt one two three ➜ cat new-stuff.txt zero one two three four five ➜ cat new-stuff.txt | xtee stuff.txt --append --unique zero four five ➜ cat stuff.txt one two three zero four five
Note that the new lines added to
stuff.txt
are also sent tostdout
, this allows for them to be redirected to another file:➜ cat new-stuff.txt | xtee stuff.txt --append --unique > added-lines.txt ➜ cat added-lines.txt zero four five
-
Deduplicating Files
➜ cat stuff.txt zero one two three zero four five five ➜ cat stuff.txt | xtee stuff.txt --soak --unique zero one two three four five ➜ cat stuff.txt zero one two three four five
Note the use of
--soak
, it makes the utility soak up all its input before writing to a file. This is useful for reading from and writing to the same file in a single pipeline.
We welcome contributions! Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.
This utility is licensed under the MIT license. You are free to use, modify, and distribute it, as long as you follow the terms of the license. You can find the full license text in the repository - Full MIT license text.
A huge thanks to all the contributors who have helped make xtee
what it is today!
If you're interested in more utilities like this, check out:
tomnomnom/anew ◇ rwese/anew ◇ tee (coreutils) ◇ sponge (moreutils)