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

Why doesn't Anakin's lightsaber explode when it's chopped in half on Geonosis?

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

Deep Learning based time series forecasting

Can I activate an iPhone without an Apple ID?

Krazy language in Krazy Kat, 25 July 1936

What is the German equivalent of 干物女 (dried fish woman)?

Commutator subgroup of Heisenberg group.

Are lithium batteries allowed in the International Space Station?

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

What impact would a dragon the size of Asia have on the environment?

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

Can someone explain this logical statement?

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

Why do legislative committees exist?

What caused Windows ME's terrible reputation?

Spider-Man: Far From Home - Why do they take a detour to Dorset?

3D-Plot with an inequality condition for parameter values

Possible isometry groups of open manifolds

Align by center of symbol

Do native speakers use ZVE or CPU?

How would you write do the dialogues of two characters talking in a chat room?

What are some symbols representing peasants/oppressed persons fighting back?

Could the crash sites of the Apollo 11 and 16 LMs be seen by the LRO?

Project Euler, problem # 9, Pythagorean triplet



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


















3














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









    3














    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



























      3














      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

























        3












        3








        3







        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

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її