How can I view gzipped files in less without having to type zless?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
25
down vote

favorite
9












I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?










share|improve this question



























    up vote
    25
    down vote

    favorite
    9












    I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?










    share|improve this question

























      up vote
      25
      down vote

      favorite
      9









      up vote
      25
      down vote

      favorite
      9






      9





      I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?










      share|improve this question















      I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?







      less compression






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 30 '11 at 18:34









      Gilles

      516k12210271556




      516k12210271556










      asked Apr 30 '11 at 18:20









      Ryan Thompson

      3,46332222




      3,46332222




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          27
          down vote



          accepted










          You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.



          The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:



          #env
          LESSOPEN=|/bin/lesspipe %s





          share|improve this answer



























            up vote
            28
            down vote













            Use zcat, then pipe it to less.



            $ zcat $FILE | less





            share|improve this answer


















            • 1




              I would prefer if less just worked on compressed files.
              – Ryan Thompson
              May 6 '11 at 18:37






            • 2




              Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
              – Pavel Vlasov
              Dec 8 '14 at 11:43











            • This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
              – Max Williams
              Jul 4 at 7:31


















            up vote
            1
            down vote













            I'm using IBM and when using zcat, it will complains that it can't find the file ending with .Z.



            On IBM one can use gzcat:



            $ gzcat log_file.gz | less





            share|improve this answer




















            • What do you mean by "using IBM"? Do you mean AIX?
              – Duncan X Simpson
              Sep 29 at 18:11

















            up vote
            0
            down vote













            Viet's answer is also necessary on Solaris 5



            $ gzcat log_file.gz | less





            share








            New contributor




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

















              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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              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%2f12383%2fhow-can-i-view-gzipped-files-in-less-without-having-to-type-zless%23new-answer', 'question_page');

              );

              Post as a guest






























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              27
              down vote



              accepted










              You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.



              The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:



              #env
              LESSOPEN=|/bin/lesspipe %s





              share|improve this answer
























                up vote
                27
                down vote



                accepted










                You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.



                The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:



                #env
                LESSOPEN=|/bin/lesspipe %s





                share|improve this answer






















                  up vote
                  27
                  down vote



                  accepted







                  up vote
                  27
                  down vote



                  accepted






                  You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.



                  The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:



                  #env
                  LESSOPEN=|/bin/lesspipe %s





                  share|improve this answer












                  You can configure the key bindings and set many settings for less in a file called ~/.lesskey. Once you've created the file, run the lesskey command; it generates a file called ~/.less which less reads when it starts.



                  The setting you want is LESSOPEN. It's an input formatter for less. The less package comes with a sample formatter in /bin/lesspipe; it decompresses gzipped files, shows content listings for many multi-file archive formats, and converts several formatted texts formats to plain text. In your ~/.lesskey:



                  #env
                  LESSOPEN=|/bin/lesspipe %s






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 30 '11 at 18:34









                  Gilles

                  516k12210271556




                  516k12210271556






















                      up vote
                      28
                      down vote













                      Use zcat, then pipe it to less.



                      $ zcat $FILE | less





                      share|improve this answer


















                      • 1




                        I would prefer if less just worked on compressed files.
                        – Ryan Thompson
                        May 6 '11 at 18:37






                      • 2




                        Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                        – Pavel Vlasov
                        Dec 8 '14 at 11:43











                      • This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                        – Max Williams
                        Jul 4 at 7:31















                      up vote
                      28
                      down vote













                      Use zcat, then pipe it to less.



                      $ zcat $FILE | less





                      share|improve this answer


















                      • 1




                        I would prefer if less just worked on compressed files.
                        – Ryan Thompson
                        May 6 '11 at 18:37






                      • 2




                        Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                        – Pavel Vlasov
                        Dec 8 '14 at 11:43











                      • This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                        – Max Williams
                        Jul 4 at 7:31













                      up vote
                      28
                      down vote










                      up vote
                      28
                      down vote









                      Use zcat, then pipe it to less.



                      $ zcat $FILE | less





                      share|improve this answer














                      Use zcat, then pipe it to less.



                      $ zcat $FILE | less






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited May 6 '11 at 7:42









                      Michael Mrozek♦

                      59.3k27187208




                      59.3k27187208










                      answered May 6 '11 at 7:09









                      Alex

                      28122




                      28122







                      • 1




                        I would prefer if less just worked on compressed files.
                        – Ryan Thompson
                        May 6 '11 at 18:37






                      • 2




                        Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                        – Pavel Vlasov
                        Dec 8 '14 at 11:43











                      • This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                        – Max Williams
                        Jul 4 at 7:31













                      • 1




                        I would prefer if less just worked on compressed files.
                        – Ryan Thompson
                        May 6 '11 at 18:37






                      • 2




                        Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                        – Pavel Vlasov
                        Dec 8 '14 at 11:43











                      • This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                        – Max Williams
                        Jul 4 at 7:31








                      1




                      1




                      I would prefer if less just worked on compressed files.
                      – Ryan Thompson
                      May 6 '11 at 18:37




                      I would prefer if less just worked on compressed files.
                      – Ryan Thompson
                      May 6 '11 at 18:37




                      2




                      2




                      Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                      – Pavel Vlasov
                      Dec 8 '14 at 11:43





                      Unlike the accepted answer this one is a clean and unix-way solution. Thanks!
                      – Pavel Vlasov
                      Dec 8 '14 at 11:43













                      This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                      – Max Williams
                      Jul 4 at 7:31





                      This is as simple as it gets, win. One thing to bear in mind is that if you open a large file with less, it opens in a useable way, straight away. With this approach, it will open but you won't be able to do much (if anything) until the compression has finished running it all through the pipe. So if you're planning on opening it repeatedly, it's better to decompress it first. Otherwise, do this and check your emails or something :)
                      – Max Williams
                      Jul 4 at 7:31











                      up vote
                      1
                      down vote













                      I'm using IBM and when using zcat, it will complains that it can't find the file ending with .Z.



                      On IBM one can use gzcat:



                      $ gzcat log_file.gz | less





                      share|improve this answer




















                      • What do you mean by "using IBM"? Do you mean AIX?
                        – Duncan X Simpson
                        Sep 29 at 18:11














                      up vote
                      1
                      down vote













                      I'm using IBM and when using zcat, it will complains that it can't find the file ending with .Z.



                      On IBM one can use gzcat:



                      $ gzcat log_file.gz | less





                      share|improve this answer




















                      • What do you mean by "using IBM"? Do you mean AIX?
                        – Duncan X Simpson
                        Sep 29 at 18:11












                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote









                      I'm using IBM and when using zcat, it will complains that it can't find the file ending with .Z.



                      On IBM one can use gzcat:



                      $ gzcat log_file.gz | less





                      share|improve this answer












                      I'm using IBM and when using zcat, it will complains that it can't find the file ending with .Z.



                      On IBM one can use gzcat:



                      $ gzcat log_file.gz | less






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Dec 14 '17 at 13:30









                      Viet

                      1214




                      1214











                      • What do you mean by "using IBM"? Do you mean AIX?
                        – Duncan X Simpson
                        Sep 29 at 18:11
















                      • What do you mean by "using IBM"? Do you mean AIX?
                        – Duncan X Simpson
                        Sep 29 at 18:11















                      What do you mean by "using IBM"? Do you mean AIX?
                      – Duncan X Simpson
                      Sep 29 at 18:11




                      What do you mean by "using IBM"? Do you mean AIX?
                      – Duncan X Simpson
                      Sep 29 at 18:11










                      up vote
                      0
                      down vote













                      Viet's answer is also necessary on Solaris 5



                      $ gzcat log_file.gz | less





                      share








                      New contributor




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





















                        up vote
                        0
                        down vote













                        Viet's answer is also necessary on Solaris 5



                        $ gzcat log_file.gz | less





                        share








                        New contributor




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



















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Viet's answer is also necessary on Solaris 5



                          $ gzcat log_file.gz | less





                          share








                          New contributor




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









                          Viet's answer is also necessary on Solaris 5



                          $ gzcat log_file.gz | less






                          share








                          New contributor




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








                          share


                          share






                          New contributor




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









                          answered 8 mins ago









                          John

                          11




                          11




                          New contributor




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





                          New contributor





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






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



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f12383%2fhow-can-i-view-gzipped-files-in-less-without-having-to-type-zless%23new-answer', 'question_page');

                              );

                              Post as a guest