File
Tenzir supports reading from and writing to files, including non-regular files, such as Unix domain sockets, standard input, standard output, and standard error.
When ~
is the first character in the file path, the operator substitutes it
with the $HOME
environment variable.
Examples
Read a file
Read from a file and parse it in the format applied by the file extension:
The from
operator automatically decompresses the
file, if the suffix list contains a supported compression
algorithm:
Some operators perform better when the entire file arrives as a single block of
bytes, such as the yara
operator. In this
case, passing mmap=true
runs more efficiently:
Follow a file
A pipeline typically completes once it reads the end of a file. Pass
follow=true
to disable this behavior and instead wait for new data written to
it. This is similar to running tail -f
on a file.
from "/tmp/never-ending-stream.ndjson", follow=true
Write a file
Write to a file in the format implied by the file extension:
The to
operator automatically compresses the
file, if the suffix list contains a supported compression
algorithm:
Append to a file
In case the file exists and you do not want to overwrite it, pass append=true
as option:
Read/write a Unix domain socket
Pass uds=true
to signal that the file is a Unix domain socket:
When reading from a Unix domain socket, Tenzir automatically figures out whether the file is regular or a socket: