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;








5















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.










share|improve this question



















  • 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


















5















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.










share|improve this question



















  • 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














5












5








5








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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













  • 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











1 Answer
1






active

oldest

votes


















18














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.






share|improve this answer

























    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
    );



    );













    draft saved

    draft discarded


















    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









    18














    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.






    share|improve this answer



























      18














      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.






      share|improve this answer

























        18












        18








        18







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 14 at 21:38









        filbrandenfilbranden

        12.9k2 gold badges25 silver badges54 bronze badges




        12.9k2 gold badges25 silver badges54 bronze badges



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림