xtee is a command-line utility for reading from standard input and writing to both standard output and file, providing powerful features for file manipulation and data processing. It combines the functionality of tee, the soaking behavior of sponge, and more.
- Supports streams spliting, incoming standard input into standard output and file
- Supports soaking up input before writing, enabling safe in-place processing
- Supports appending and overwriting the destination entirely
- Supports deduplication, keeping destination unique
- 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.gzTip
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 -xzvNote
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
xteebinary 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
xteeto 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 -hhelp message:
_
__ _| |_ ___ ___
\ \/ / __/ _ \/ _ \
> <| || __/ __/
/_/\_\\__\___|\___|
v1.0.0
USAGE:
xtee [OPTION]... <FILE>
INPUT:
--soak bool buffer input before processing
OUTPUT:
--append bool append lines
--unique bool unique lines
--preview bool preview lines
-q, --quiet bool suppress stdout
-m, --monochrome bool stdout in monochrome
-s, --silent bool stdout in silent mode
-v, --verbose bool stdout in verbose mode
echo "zero" | xtee stuff.txtcat stuff.txtzero
cat duplicates.txtzero
one
two
three
zero
four
five
five
cat duplicates.txt | xtee --unique deduplicated.txtzero
one
two
three
four
five
cat deduplicated.txtzero
one
two
three
four
five
cat stuff.txtzero
one
two
three
zero
four
five
five
cat stuff.txt | xtee stuff.txt --soak --uniquezero
one
two
three
four
five
cat stuff.txtzero
one
two
three
four
five
Note
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.
cat stuff.txtone
two
three
cat new-stuff.txtzero
one
two
three
four
five
cat new-stuff.txt | xtee stuff.txt --append zero
one
two
three
four
five
cat stuff.txtone
two
three
zero
one
two
three
four
five
cat stuff.txtone
two
three
cat new-stuff.txtzero
one
two
three
four
five
cat new-stuff.txt | xtee stuff.txt --append --uniquezero
four
five
cat stuff.txtone
two
three
zero
four
five
Note
Note that the new lines added to stuff.txt are also sent to stdout, this allows for them to be redirected to another file:
cat new-stuff.txt | xtee stuff.txt --append --unique > added-lines.txtcat added-lines.txtzero
four
five
- For large files (>1GB),
--soakmode will use significant memory as it buffers everything --uniquemode maintains all seen lines in memory - be cautious with huge datasets- Stream processing (without
--soak) is most memory-efficient for large inputs
Contributions are welcome and encouraged! Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.
A big thank you to all the contributors for your ongoing support!
This package 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.