Writing to disk and compress with xz at the same timeHow to convert all files from gzip to xz on the fly (and recursively)?Named pipes: several experiments leads to confusion“Leaky” pipes in linuxHow to convert all files from gzip to xz on the fly (and recursively)?How does pv work?Are pipe reads not greater than PIPE_BUF atomic?On-the-fly stream compression that doesn't spill over into hardware resources?How to concatenate results of multiple commands and pipe into another without intermediate file?How do pipelines limit memory usage?Writing and Executing Program to behave like consoleFlush the pipe/printf buffers externally for already running process with known PID
Where is this photo of a group of hikers taken? Is it really in the Ural?
What exactly makes a General Products hull nearly indestructible?
Correct use of smash with math and root signs
dos2unix is unable to convert typescript file to unix format
What is the purpose of this "red room" in "Stranger Things"?
Sometimes you are this word with three vowels
Why is a dedicated QA team member necessary?
Why do people say "I am broke" instead of "I am broken"?
How to correct errors in proofs of an accepted paper
The seven story archetypes. Are they truly all of them?
Why can't a country print its own money to spend it only abroad?
Alternative methods for solving a system of one linear one non linear simultaneous equations
Why did NASA use Imperial units?
Sci-fi short story: plants attracting spaceship and using them as a agents of pollination between two planets
If a check is written for bill, but account number is not mentioned on memo line, is it still processed?
Using paddles to support a bug net
Inverse Colombian Function
Using "Kollege" as "university friend"?
Why are there not any MRI machines available in Interstellar?
How could Barty Crouch Jr. have run out of Polyjuice Potion at the end of the Goblet of Fire movie?
How can Kazakhstan perform MITM attacks on all HTTPS traffic?
Can 々 stand for a duplicated kanji with a different reading?
German phrase for 'suited and booted'
From the start of the game what is the longest possible series of consecutive white moves where white can do those moves no matter what black does?
Writing to disk and compress with xz at the same time
How to convert all files from gzip to xz on the fly (and recursively)?Named pipes: several experiments leads to confusion“Leaky” pipes in linuxHow to convert all files from gzip to xz on the fly (and recursively)?How does pv work?Are pipe reads not greater than PIPE_BUF atomic?On-the-fly stream compression that doesn't spill over into hardware resources?How to concatenate results of multiple commands and pipe into another without intermediate file?How do pipelines limit memory usage?Writing and Executing Program to behave like consoleFlush the pipe/printf buffers externally for already running process with known PID
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a program that writes traces on disk and the size becomes very large. Normally, I use the following commands.
./run output.txt
xz output.txt
Can I pipe xz at the same time as output.txt is being written?
I read How to convert all files from gzip to xz on the fly (and recursively)?, but I am not sure it applies in my case.
bash pipe xz
add a comment |
I have a program that writes traces on disk and the size becomes very large. Normally, I use the following commands.
./run output.txt
xz output.txt
Can I pipe xz at the same time as output.txt is being written?
I read How to convert all files from gzip to xz on the fly (and recursively)?, but I am not sure it applies in my case.
bash pipe xz
1
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44
add a comment |
I have a program that writes traces on disk and the size becomes very large. Normally, I use the following commands.
./run output.txt
xz output.txt
Can I pipe xz at the same time as output.txt is being written?
I read How to convert all files from gzip to xz on the fly (and recursively)?, but I am not sure it applies in my case.
bash pipe xz
I have a program that writes traces on disk and the size becomes very large. Normally, I use the following commands.
./run output.txt
xz output.txt
Can I pipe xz at the same time as output.txt is being written?
I read How to convert all files from gzip to xz on the fly (and recursively)?, but I am not sure it applies in my case.
bash pipe xz
bash pipe xz
edited Jul 16 at 0:11
Peter Mortensen
9486 silver badges9 bronze badges
9486 silver badges9 bronze badges
asked Jul 14 at 20:31
mahmoodmahmood
4212 gold badges10 silver badges23 bronze badges
4212 gold badges10 silver badges23 bronze badges
1
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44
add a comment |
1
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44
1
1
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44
add a comment |
1 Answer
1
active
oldest
votes
If your ./run will produce its output to stdout if not given a file argument (which is customary in Unix/Linux), then you can simply use:
./run | xz -c >output.txt.xz
If it needs a filename argument, but if it's fine writing to a pipe, then you can either use a special device such as /dev/stdout or /dev/fd/1 (both should be equivalent), like so:
./run /dev/stdout | xz -c >output.txt.xz
Or you can use process substitution, which is typically available in most modern shells such as bash, zsh, or ksh, which will end up using a device from /dev/fd behind the scenes to accomplish the same:
./run >(xz -c >output.txt.xz)
This last one also needs ./run to be able to write to a pipe, but it should work better than the others if ./run writes to output.txt and to stdout in its normal operation, in which case the output would get mixed up if you redirect both to stdout.
Programs are usually ok writing to a pipe, but some of them might want to seek and rewind to offsets within an output file, which is not possible in a pipe. If that's the case, then writing to a temporary file and then compressing it is probably all you can do.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f530148%2fwriting-to-disk-and-compress-with-xz-at-the-same-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If your ./run will produce its output to stdout if not given a file argument (which is customary in Unix/Linux), then you can simply use:
./run | xz -c >output.txt.xz
If it needs a filename argument, but if it's fine writing to a pipe, then you can either use a special device such as /dev/stdout or /dev/fd/1 (both should be equivalent), like so:
./run /dev/stdout | xz -c >output.txt.xz
Or you can use process substitution, which is typically available in most modern shells such as bash, zsh, or ksh, which will end up using a device from /dev/fd behind the scenes to accomplish the same:
./run >(xz -c >output.txt.xz)
This last one also needs ./run to be able to write to a pipe, but it should work better than the others if ./run writes to output.txt and to stdout in its normal operation, in which case the output would get mixed up if you redirect both to stdout.
Programs are usually ok writing to a pipe, but some of them might want to seek and rewind to offsets within an output file, which is not possible in a pipe. If that's the case, then writing to a temporary file and then compressing it is probably all you can do.
add a comment |
If your ./run will produce its output to stdout if not given a file argument (which is customary in Unix/Linux), then you can simply use:
./run | xz -c >output.txt.xz
If it needs a filename argument, but if it's fine writing to a pipe, then you can either use a special device such as /dev/stdout or /dev/fd/1 (both should be equivalent), like so:
./run /dev/stdout | xz -c >output.txt.xz
Or you can use process substitution, which is typically available in most modern shells such as bash, zsh, or ksh, which will end up using a device from /dev/fd behind the scenes to accomplish the same:
./run >(xz -c >output.txt.xz)
This last one also needs ./run to be able to write to a pipe, but it should work better than the others if ./run writes to output.txt and to stdout in its normal operation, in which case the output would get mixed up if you redirect both to stdout.
Programs are usually ok writing to a pipe, but some of them might want to seek and rewind to offsets within an output file, which is not possible in a pipe. If that's the case, then writing to a temporary file and then compressing it is probably all you can do.
add a comment |
If your ./run will produce its output to stdout if not given a file argument (which is customary in Unix/Linux), then you can simply use:
./run | xz -c >output.txt.xz
If it needs a filename argument, but if it's fine writing to a pipe, then you can either use a special device such as /dev/stdout or /dev/fd/1 (both should be equivalent), like so:
./run /dev/stdout | xz -c >output.txt.xz
Or you can use process substitution, which is typically available in most modern shells such as bash, zsh, or ksh, which will end up using a device from /dev/fd behind the scenes to accomplish the same:
./run >(xz -c >output.txt.xz)
This last one also needs ./run to be able to write to a pipe, but it should work better than the others if ./run writes to output.txt and to stdout in its normal operation, in which case the output would get mixed up if you redirect both to stdout.
Programs are usually ok writing to a pipe, but some of them might want to seek and rewind to offsets within an output file, which is not possible in a pipe. If that's the case, then writing to a temporary file and then compressing it is probably all you can do.
If your ./run will produce its output to stdout if not given a file argument (which is customary in Unix/Linux), then you can simply use:
./run | xz -c >output.txt.xz
If it needs a filename argument, but if it's fine writing to a pipe, then you can either use a special device such as /dev/stdout or /dev/fd/1 (both should be equivalent), like so:
./run /dev/stdout | xz -c >output.txt.xz
Or you can use process substitution, which is typically available in most modern shells such as bash, zsh, or ksh, which will end up using a device from /dev/fd behind the scenes to accomplish the same:
./run >(xz -c >output.txt.xz)
This last one also needs ./run to be able to write to a pipe, but it should work better than the others if ./run writes to output.txt and to stdout in its normal operation, in which case the output would get mixed up if you redirect both to stdout.
Programs are usually ok writing to a pipe, but some of them might want to seek and rewind to offsets within an output file, which is not possible in a pipe. If that's the case, then writing to a temporary file and then compressing it is probably all you can do.
answered Jul 14 at 21:38
filbrandenfilbranden
12.9k2 gold badges25 silver badges54 bronze badges
12.9k2 gold badges25 silver badges54 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f530148%2fwriting-to-disk-and-compress-with-xz-at-the-same-time%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.
– Janka
Jul 14 at 20:44