>
)Writes stdin to disk - overwriting contents if file already exists
Redirects output to file.
If a file already exists, the contents will be truncated (overwritten). Otherwise a new file is created.
<stdin> |> [ -i | --ignore-pipeline-check ] filename
<stdin> |> [ -w | --wait-for-eof ] filename
g * |> files.txt
--ignore-pipeline-check
Don’t check if filename is a parameter for an earlier command in the pipeline--wait-for-eof
Wait for stdin to return an EOF before opening filename-i
Alias for --ignore-pipeline
-w
Alias for --wait-for-eof
If no flags are specified, then |>
will check if the filename supplied is used in any parameters for other commands in the pipeline. If it has been, then |>
will wait for an EOF (End Of File) from stdin before opening filename.
This is to allow pipelines like the following:
open example.log | regexp m/error/ |> example.log
Under traditional shells and Murex’s normal scheduler, all commands in a pipeline would run concurrently. This leads to a race condition where |>
opens (and thus truncates) a file before other commands can read from it.
However by default, |>
will check the pipeline to look for any other references of filename and if it exists, it will wait for an EOF before |>
truncates filename.
This wait for EOF behaviour can be forced with the --wait-for-eof
/ -w
flag.
Alternatively, if you want to force |>
to run concurrently then you can disable the pipeline check with the --ignore-pipeline-check
/ -i
flag.
WARNING! Waiting for EOF will cause
|>
to cache the pipeline into RAM. If your pipeline is parsing multi-gigabyte or larger files then you may experience performance issues.
For large datasets, it might be preferable to write to a temporary file first.
open example.log | regexp m/error/ |> example.log.tmp
mv example.log.tmp example.log
The move operation should be instantaneous on most filesystems because your operating system will just alter filesystem metadata rather than move the file contents.
If you specify a flag without a filename, eg |> --wait-for-eof
, then it is assumed that the flag is the filename.
While |>
is referred to as an operator, it’s actually a pipe followed by a builtin:
out "foobar" | > example.txt
Thus you can actually use >
by itself.
If >
is at the start of a pipeline then it is treated as null input. This a convenient shortcut to create an empty file or blank an existing file.
Create a new empty file:
> newfile
Clear a large log file without deleting the file itself:
> large.log
To append a file (ie write at the end of the file without overwriting its contents) use >>
instead.
>
|>
fwrite
pipe
): Manage Murex named pipestmp
): Create a temporary file and write to itg
): Glob pattern matching for file system objects (eg *.txt
)<pipe>
): Reads from a Murex named pipe->
Arrow Pipe: Pipes stdout from the left hand command to stdin of the right hand command>>
Append File: Writes stdin to disk - appending contents if file already exists?
stderr Pipe: Pipes stderr from the left hand command to stdin of the right hand command (DEPRECATED)|
POSIX Pipe: Pipes stdout from the left hand command to stdin of the right hand commandThis document was generated from builtins/core/io/write_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Tue Dec 10 22:56:57 UTC 2024 against commit 60f05a260f05a227caf73dd5b3478e3cb3f4bb24e46745b.
Current version is 6.4.1005 (develop) which has been verified against tests cases.