Using zcat and gzip in linux Announcing the arrival of Valued Associate #679: Cesar Manara ...

Do I really need recursive chmod to restrict access to a folder?

How do I keep my slimes from escaping their pens?

Okay to merge included columns on otherwise identical indexes?

Denied boarding although I have proper visa and documentation. To whom should I make a complaint?

How to align text above triangle figure

English words in a non-english sci-fi novel

Using audio cues to encourage good posture

How do pianists reach extremely loud dynamics?

Fundamental Solution of the Pell Equation

Compare a given version number in the form major.minor.build.patch and see if one is less than the other

Why are both D and D# fitting into my E minor key?

What does F' and F" mean?

How to find out what spells would be useless to a blind NPC spellcaster?

How to override model in magento2?

How do I stop a creek from eroding my steep embankment?

In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?

List of Python versions

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

What would be the ideal power source for a cybernetic eye?

What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?

Apollo command module space walk?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

Book where humans were engineered with genes from animal species to survive hostile planets

Echoing a tail command produces unexpected output?



Using zcat and gzip in linux



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How do I recover lost/inaccessible data from my storage device?What should do now that I have accidentally truncated a file I don't have a backup of?What Linux archiver supports splitting archive into pieces?In Linux, how to ls -l a directory and not the contents of that directory?Time Command - Debian Linux Serverrecursively unzip filenames with spaces in linux and save logMerging 2 zip filesCompare two files and output the differencesConcatenate four binary files using alternating pattern in LinuxMerge xml files using Linux shell scriptingLinux zip -i recursivelyComparing two large files in Linux without exhausing memory





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I used zcat and gzip to merge and zip the files using:



zcat file1.fastq.gz file2.fastq.gz | gzip -c > file1.fastq.gz


Now, I have 0 bytes file1.fastq.gz



Please advise?










share|improve this question









New contributor




raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I used zcat and gzip to merge and zip the files using:



    zcat file1.fastq.gz file2.fastq.gz | gzip -c > file1.fastq.gz


    Now, I have 0 bytes file1.fastq.gz



    Please advise?










    share|improve this question









    New contributor




    raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I used zcat and gzip to merge and zip the files using:



      zcat file1.fastq.gz file2.fastq.gz | gzip -c > file1.fastq.gz


      Now, I have 0 bytes file1.fastq.gz



      Please advise?










      share|improve this question









      New contributor




      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I used zcat and gzip to merge and zip the files using:



      zcat file1.fastq.gz file2.fastq.gz | gzip -c > file1.fastq.gz


      Now, I have 0 bytes file1.fastq.gz



      Please advise?







      linux






      share|improve this question









      New contributor




      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 18 hours ago









      Attie

      13.3k43649




      13.3k43649






      New contributor




      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 18 hours ago









      raman sethiraman sethi

      11




      11




      New contributor




      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      raman sethi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          When you use the > redirection, the shell will open the named file (file1.fastq.gz) for writing and truncate it to zero length. (documentation)



          Next, zcat will run, with file1.fastq.gz and file2.fastq.gz as input files .



          At this point, zcat throws an error, because the input file (file1.fastq.gz) has no content - not even the GZip header - and the pipeline falls apart.



          You may find that file1.fastq.gz is actually a few bytes in size (not zero), and this will be caused by gzip compressing and writing its null input.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file1.gz

          gzip: file1.gz: unexpected end of file
          $ stat -c '%s bytes' file1.gz
          20 bytes


          It's worth looking out for error messages like this.





          There are a couple of viable solutions, but they depend on the size of your data.



          In all situations, without some clever tricks, you will need to have enough space to store both the original and the new output file on disk at once.



          Write to Another File



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file_all.gz
          $ gzip -d < file_all.gz
          foo
          bar


          Use sponge



          If the data isn't too large, then the sponge utility will handle this situation for you. All data read from stdin is "soaked up" before any data is written to the output file.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c | sponge file1.gz
          $ gzip -d < file1.gz
          foo
          bar





          share|improve this answer
























          • Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

            – raman sethi
            17 hours ago











          • Is it possible to recover the old file? Thanks

            – raman sethi
            17 hours ago











          • The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

            – raman sethi
            17 hours ago











          • "Is it possible to recover the old file?" probably not... can you get / create it again?

            – Attie
            16 hours ago











          • "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

            – ssice
            14 hours ago












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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
          });


          }
          });






          raman sethi is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1426061%2fusing-zcat-and-gzip-in-linux%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









          0














          When you use the > redirection, the shell will open the named file (file1.fastq.gz) for writing and truncate it to zero length. (documentation)



          Next, zcat will run, with file1.fastq.gz and file2.fastq.gz as input files .



          At this point, zcat throws an error, because the input file (file1.fastq.gz) has no content - not even the GZip header - and the pipeline falls apart.



          You may find that file1.fastq.gz is actually a few bytes in size (not zero), and this will be caused by gzip compressing and writing its null input.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file1.gz

          gzip: file1.gz: unexpected end of file
          $ stat -c '%s bytes' file1.gz
          20 bytes


          It's worth looking out for error messages like this.





          There are a couple of viable solutions, but they depend on the size of your data.



          In all situations, without some clever tricks, you will need to have enough space to store both the original and the new output file on disk at once.



          Write to Another File



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file_all.gz
          $ gzip -d < file_all.gz
          foo
          bar


          Use sponge



          If the data isn't too large, then the sponge utility will handle this situation for you. All data read from stdin is "soaked up" before any data is written to the output file.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c | sponge file1.gz
          $ gzip -d < file1.gz
          foo
          bar





          share|improve this answer
























          • Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

            – raman sethi
            17 hours ago











          • Is it possible to recover the old file? Thanks

            – raman sethi
            17 hours ago











          • The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

            – raman sethi
            17 hours ago











          • "Is it possible to recover the old file?" probably not... can you get / create it again?

            – Attie
            16 hours ago











          • "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

            – ssice
            14 hours ago
















          0














          When you use the > redirection, the shell will open the named file (file1.fastq.gz) for writing and truncate it to zero length. (documentation)



          Next, zcat will run, with file1.fastq.gz and file2.fastq.gz as input files .



          At this point, zcat throws an error, because the input file (file1.fastq.gz) has no content - not even the GZip header - and the pipeline falls apart.



          You may find that file1.fastq.gz is actually a few bytes in size (not zero), and this will be caused by gzip compressing and writing its null input.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file1.gz

          gzip: file1.gz: unexpected end of file
          $ stat -c '%s bytes' file1.gz
          20 bytes


          It's worth looking out for error messages like this.





          There are a couple of viable solutions, but they depend on the size of your data.



          In all situations, without some clever tricks, you will need to have enough space to store both the original and the new output file on disk at once.



          Write to Another File



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file_all.gz
          $ gzip -d < file_all.gz
          foo
          bar


          Use sponge



          If the data isn't too large, then the sponge utility will handle this situation for you. All data read from stdin is "soaked up" before any data is written to the output file.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c | sponge file1.gz
          $ gzip -d < file1.gz
          foo
          bar





          share|improve this answer
























          • Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

            – raman sethi
            17 hours ago











          • Is it possible to recover the old file? Thanks

            – raman sethi
            17 hours ago











          • The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

            – raman sethi
            17 hours ago











          • "Is it possible to recover the old file?" probably not... can you get / create it again?

            – Attie
            16 hours ago











          • "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

            – ssice
            14 hours ago














          0












          0








          0







          When you use the > redirection, the shell will open the named file (file1.fastq.gz) for writing and truncate it to zero length. (documentation)



          Next, zcat will run, with file1.fastq.gz and file2.fastq.gz as input files .



          At this point, zcat throws an error, because the input file (file1.fastq.gz) has no content - not even the GZip header - and the pipeline falls apart.



          You may find that file1.fastq.gz is actually a few bytes in size (not zero), and this will be caused by gzip compressing and writing its null input.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file1.gz

          gzip: file1.gz: unexpected end of file
          $ stat -c '%s bytes' file1.gz
          20 bytes


          It's worth looking out for error messages like this.





          There are a couple of viable solutions, but they depend on the size of your data.



          In all situations, without some clever tricks, you will need to have enough space to store both the original and the new output file on disk at once.



          Write to Another File



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file_all.gz
          $ gzip -d < file_all.gz
          foo
          bar


          Use sponge



          If the data isn't too large, then the sponge utility will handle this situation for you. All data read from stdin is "soaked up" before any data is written to the output file.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c | sponge file1.gz
          $ gzip -d < file1.gz
          foo
          bar





          share|improve this answer













          When you use the > redirection, the shell will open the named file (file1.fastq.gz) for writing and truncate it to zero length. (documentation)



          Next, zcat will run, with file1.fastq.gz and file2.fastq.gz as input files .



          At this point, zcat throws an error, because the input file (file1.fastq.gz) has no content - not even the GZip header - and the pipeline falls apart.



          You may find that file1.fastq.gz is actually a few bytes in size (not zero), and this will be caused by gzip compressing and writing its null input.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file1.gz

          gzip: file1.gz: unexpected end of file
          $ stat -c '%s bytes' file1.gz
          20 bytes


          It's worth looking out for error messages like this.





          There are a couple of viable solutions, but they depend on the size of your data.



          In all situations, without some clever tricks, you will need to have enough space to store both the original and the new output file on disk at once.



          Write to Another File



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c > file_all.gz
          $ gzip -d < file_all.gz
          foo
          bar


          Use sponge



          If the data isn't too large, then the sponge utility will handle this situation for you. All data read from stdin is "soaked up" before any data is written to the output file.



          $ echo "foo" | gzip > file1.gz
          $ echo "bar" | gzip > file2.gz
          $ zcat file1.gz file2.gz | gzip -c | sponge file1.gz
          $ gzip -d < file1.gz
          foo
          bar






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 17 hours ago









          AttieAttie

          13.3k43649




          13.3k43649













          • Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

            – raman sethi
            17 hours ago











          • Is it possible to recover the old file? Thanks

            – raman sethi
            17 hours ago











          • The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

            – raman sethi
            17 hours ago











          • "Is it possible to recover the old file?" probably not... can you get / create it again?

            – Attie
            16 hours ago











          • "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

            – ssice
            14 hours ago



















          • Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

            – raman sethi
            17 hours ago











          • Is it possible to recover the old file? Thanks

            – raman sethi
            17 hours ago











          • The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

            – raman sethi
            17 hours ago











          • "Is it possible to recover the old file?" probably not... can you get / create it again?

            – Attie
            16 hours ago











          • "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

            – ssice
            14 hours ago

















          Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

          – raman sethi
          17 hours ago





          Thank you for your answer. You are right, it is not empty. I tried these commands but it didn't work

          – raman sethi
          17 hours ago













          Is it possible to recover the old file? Thanks

          – raman sethi
          17 hours ago





          Is it possible to recover the old file? Thanks

          – raman sethi
          17 hours ago













          The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

          – raman sethi
          17 hours ago





          The file 1 is 20 bytes while file 2 is 2.3GB, the file 1 was earlier 2.3 GB, i want to get both file 1 and file 2 as 2.3 GB

          – raman sethi
          17 hours ago













          "Is it possible to recover the old file?" probably not... can you get / create it again?

          – Attie
          16 hours ago





          "Is it possible to recover the old file?" probably not... can you get / create it again?

          – Attie
          16 hours ago













          "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

          – ssice
          14 hours ago





          "is it possible to recover the old file?" superuser.com/questions/1124811/… superuser.com/questions/241817/…

          – ssice
          14 hours ago










          raman sethi is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          raman sethi is a new contributor. Be nice, and check out our Code of Conduct.













          raman sethi is a new contributor. Be nice, and check out our Code of Conduct.












          raman sethi is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1426061%2fusing-zcat-and-gzip-in-linux%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

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

          looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...