writting to disk and compress with xz at the same timeHow to convert all files from gzip to xz on the fly (and recursively)?How can I tell if the pipe buffer is full?Use time ,timeout and ulimit commands properlyNamed pipes: several experiments leads to confusiongrep script - output lines at the same time into echoCan a pipe be used instead of exec in - find / -name “.txt” -exec cp /junk ;On-the-fly stream compression that doesn't spill over into hardware resources?Pipe limit data in bytesHow to concatenate results of multiple commands and pipe into another without intermediate file?Tee does not write to file when combined to pipestderr stdout to log with date and time also show output to tty but without date and time

Construct a pentagon avoiding compass use

How long do Apple retain notifications to be pushed to iOS devices until they expire?

How can I legally visit the United States Minor Outlying Islands in the Pacific?

Can a pizza stone be fixed after soap has been used to clean it?

How would someone destroy a black hole that’s at the centre of a planet?

Old short story where the future emperor of the galaxy is taken for a tour around Earth

Why linear regression uses "vertical" distance to the best-fit-line, instead of actual distance?

How to make "plastic" sounding distored guitar

What's the phrasal verb for carbonated drinks exploding out of the can after being shaken?

Alternatives to using writing paper for writing practice

Why does ffmpeg choose 10+20+20ms instead of an even 16ms for 60fps gifs?

Postgresql numeric and decimal is automatically rounding off

What exactly is the Tension force?

Are lithium batteries allowed in the International Space Station?

Deep Learning based time series forecasting

Mistakenly modified `/bin/sh'

Doing research in academia and not liking competition

What is the closed form of the following recursive function?

How did John Lennon tune his guitar

Crab Nebula short story from 1960s or '70s

Too many spies!

Project Euler, problem # 9, Pythagorean triplet

I quit, and boss offered me 3 month "grace period" where I could still come back

Why is dry soil hydrophobic? Bad gardener paradox



writting to disk and compress with xz at the same time


How to convert all files from gzip to xz on the fly (and recursively)?How can I tell if the pipe buffer is full?Use time ,timeout and ulimit commands properlyNamed pipes: several experiments leads to confusiongrep script - output lines at the same time into echoCan a pipe be used instead of exec in - find / -name “.txt” -exec cp /junk ;On-the-fly stream compression that doesn't spill over into hardware resources?Pipe limit data in bytesHow to concatenate results of multiple commands and pipe into another without intermediate file?Tee does not write to file when combined to pipestderr stdout to log with date and time also show output to tty but without date and time






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a program and writes traces on disk and the size becomes very large. Normally, I use



./run output.txt
xz output.txt


I want to know if I can pipe xz at the same time as output.txt is being written. I see this topic, but not sure it is applicable for me.










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
    8 hours ago


















1















I have a program and writes traces on disk and the size becomes very large. Normally, I use



./run output.txt
xz output.txt


I want to know if I can pipe xz at the same time as output.txt is being written. I see this topic, but not sure it is applicable for me.










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
    8 hours ago














1












1








1








I have a program and writes traces on disk and the size becomes very large. Normally, I use



./run output.txt
xz output.txt


I want to know if I can pipe xz at the same time as output.txt is being written. I see this topic, but not sure it is applicable for me.










share|improve this question














I have a program and writes traces on disk and the size becomes very large. Normally, I use



./run output.txt
xz output.txt


I want to know if I can pipe xz at the same time as output.txt is being written. I see this topic, but not sure it is applicable for me.







bash pipe xz






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









mahmoodmahmood

3992 gold badges8 silver badges23 bronze badges




3992 gold badges8 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
    8 hours ago













  • 1





    See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.

    – Janka
    8 hours ago








1




1





See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.

– Janka
8 hours ago






See if your ./run tool can write its output to stdout instead of a file. The answer depends on that.

– Janka
8 hours ago











1 Answer
1






active

oldest

votes


















4














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%2fwritting-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









    4














    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



























      4














      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

























        4












        4








        4







        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 7 hours ago









        filbrandenfilbranden

        12.4k2 gold badges22 silver badges52 bronze badges




        12.4k2 gold badges22 silver badges52 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%2fwritting-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

            ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

            Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу