How to list *.tar.gz, one filename per line?











up vote
4
down vote

favorite
1












I am trying to list .tar.gz only using the following command:



ls *.tar.gz -l



.. It shows me the following list:



-rw-rw-r-- 1 osm osm  949 Nov 27 16:17 file1.tar.gz
-rw-rw-r-- 1 osm osm 949 Nov 27 16:17 file2.tar.gz


However, I just need to list it this way:



file1.tar.gz 
file2.tar.gz


and also not:



file1.tar.gz file2.tar.gz


How to do it?









share




















  • 5




    it is a good habit to use options before filenames. and you need to use -1 instead of -l
    – AnonymousLurker
    yesterday






  • 14




    ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
    – Kusalananda
    yesterday








  • 3




    the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
    – ctrl-alt-delor
    yesterday






  • 1




    Possible duplicate of Output from ls has newlines but displays on a single line. Why?
    – Julien Lopez
    18 hours ago















up vote
4
down vote

favorite
1












I am trying to list .tar.gz only using the following command:



ls *.tar.gz -l



.. It shows me the following list:



-rw-rw-r-- 1 osm osm  949 Nov 27 16:17 file1.tar.gz
-rw-rw-r-- 1 osm osm 949 Nov 27 16:17 file2.tar.gz


However, I just need to list it this way:



file1.tar.gz 
file2.tar.gz


and also not:



file1.tar.gz file2.tar.gz


How to do it?









share




















  • 5




    it is a good habit to use options before filenames. and you need to use -1 instead of -l
    – AnonymousLurker
    yesterday






  • 14




    ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
    – Kusalananda
    yesterday








  • 3




    the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
    – ctrl-alt-delor
    yesterday






  • 1




    Possible duplicate of Output from ls has newlines but displays on a single line. Why?
    – Julien Lopez
    18 hours ago













up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I am trying to list .tar.gz only using the following command:



ls *.tar.gz -l



.. It shows me the following list:



-rw-rw-r-- 1 osm osm  949 Nov 27 16:17 file1.tar.gz
-rw-rw-r-- 1 osm osm 949 Nov 27 16:17 file2.tar.gz


However, I just need to list it this way:



file1.tar.gz 
file2.tar.gz


and also not:



file1.tar.gz file2.tar.gz


How to do it?









share















I am trying to list .tar.gz only using the following command:



ls *.tar.gz -l



.. It shows me the following list:



-rw-rw-r-- 1 osm osm  949 Nov 27 16:17 file1.tar.gz
-rw-rw-r-- 1 osm osm 949 Nov 27 16:17 file2.tar.gz


However, I just need to list it this way:



file1.tar.gz 
file2.tar.gz


and also not:



file1.tar.gz file2.tar.gz


How to do it?







ls





share














share












share



share








edited 7 hours ago









200_success

3,87911428




3,87911428










asked yesterday









McLan

1524




1524








  • 5




    it is a good habit to use options before filenames. and you need to use -1 instead of -l
    – AnonymousLurker
    yesterday






  • 14




    ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
    – Kusalananda
    yesterday








  • 3




    the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
    – ctrl-alt-delor
    yesterday






  • 1




    Possible duplicate of Output from ls has newlines but displays on a single line. Why?
    – Julien Lopez
    18 hours ago














  • 5




    it is a good habit to use options before filenames. and you need to use -1 instead of -l
    – AnonymousLurker
    yesterday






  • 14




    ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
    – Kusalananda
    yesterday








  • 3




    the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
    – ctrl-alt-delor
    yesterday






  • 1




    Possible duplicate of Output from ls has newlines but displays on a single line. Why?
    – Julien Lopez
    18 hours ago








5




5




it is a good habit to use options before filenames. and you need to use -1 instead of -l
– AnonymousLurker
yesterday




it is a good habit to use options before filenames. and you need to use -1 instead of -l
– AnonymousLurker
yesterday




14




14




ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
– Kusalananda
yesterday






ls -1 *.tar.gz, but what do you want to use the list for? If you are doing something to those filenames, then ls is not the right way to do it. See Why *not* parse `ls` (and what do to instead)?
– Kusalananda
yesterday






3




3




the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
– ctrl-alt-delor
yesterday




the manual you need is man ls. Ensure that your display font has good contrast between 1 (one) and l (lower case letter ell).
– ctrl-alt-delor
yesterday




1




1




Possible duplicate of Output from ls has newlines but displays on a single line. Why?
– Julien Lopez
18 hours ago




Possible duplicate of Output from ls has newlines but displays on a single line. Why?
– Julien Lopez
18 hours ago










5 Answers
5






active

oldest

votes

















up vote
31
down vote



accepted










The -1 option (the digit “one”, not lower-case “L”) will list one file per line with no other information:



ls -1 -- *.tar.gz





share|improve this answer

















  • 1




    Why the double dashes? ls -1 *.tar.gz works just as well.
    – RonJohn
    6 hours ago






  • 5




    @RonJohn it avoids surprises with filenames starting with -.
    – Stephen Kitt
    6 hours ago










  • Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
    – wizzwizz4
    4 hours ago




















up vote
15
down vote













If you only need the filenames, you could use printf:



printf '%sn' *.tar.gz


... the shell will expand the *.tar.gz wildcard to the filenames, then printf will print them, with each followed by a newline. This output would differ a bit from that of ls in the case of filenames with newlines embedded in them:



setup



$ touch file{1,2}.tar.gz
$ touch file$'n'3.tar.gz


ls



$ ls -1 -- *.tar.gz
file1.tar.gz
file2.tar.gz
file?3.tar.gz


printf



$ printf '%sn' *.tar.gz
file1.tar.gz
file2.tar.gz
file
3.tar.gz





share|improve this answer

















  • 6




    See also ls -b, ls -Q, ls --quoting-style=....
    – Stephen Kitt
    yesterday


















up vote
7
down vote













ls behaves differently when its output is piped. For example:



ls          # outputs filenames in columns
ls | cat # passes one filename per line to the cat command


So if you want see all your *.tar.gz files, one per line, you can do this:



ls *.tar.gz | cat


But what if you don't want to pipe your output? That is, is there a way to force ls to output the filenames one to a line without piping the output?



Yes, with the -1 switch. (That's a dash with the number 1.) So you can use these commands:



ls -1             # shows all (non-hidden) files, one per line
ls -1 *.tar.gz # shows only *.tar.gz files, one per line





share|improve this answer










New contributor




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

























    up vote
    6
    down vote













    Or with GNU find:



    find  -name "*.tar.gz"  -printf '%Pn'


    In contrary to ls with * it will search for .tar.gz files recursively:



    $ find  -name "*.tar.gz"  -printf '%Pn'
    file1.tar.gz
    dir/file3.tar.gz
    file2.tar.gz





    share|improve this answer




























      up vote
      3
      down vote













      A slightly more roundabout and loopy way:



      for i in *.tar.gz; do
      echo "$i"
      done


      EDIT: added quotes to handle weird filenames






      share|improve this answer



















      • 4




        touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
        – Jeff Schaller
        yesterday










      • oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
        – snetch
        yesterday






      • 1




        sorry! rm -- '-e a.tar.gz' should do the trick
        – Jeff Schaller
        yesterday










      • You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
        – snetch
        yesterday










      • Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
        – Jesse Steele
        2 hours ago











      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: 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%2f484481%2fhow-to-list-tar-gz-one-filename-per-line%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      31
      down vote



      accepted










      The -1 option (the digit “one”, not lower-case “L”) will list one file per line with no other information:



      ls -1 -- *.tar.gz





      share|improve this answer

















      • 1




        Why the double dashes? ls -1 *.tar.gz works just as well.
        – RonJohn
        6 hours ago






      • 5




        @RonJohn it avoids surprises with filenames starting with -.
        – Stephen Kitt
        6 hours ago










      • Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
        – wizzwizz4
        4 hours ago

















      up vote
      31
      down vote



      accepted










      The -1 option (the digit “one”, not lower-case “L”) will list one file per line with no other information:



      ls -1 -- *.tar.gz





      share|improve this answer

















      • 1




        Why the double dashes? ls -1 *.tar.gz works just as well.
        – RonJohn
        6 hours ago






      • 5




        @RonJohn it avoids surprises with filenames starting with -.
        – Stephen Kitt
        6 hours ago










      • Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
        – wizzwizz4
        4 hours ago















      up vote
      31
      down vote



      accepted







      up vote
      31
      down vote



      accepted






      The -1 option (the digit “one”, not lower-case “L”) will list one file per line with no other information:



      ls -1 -- *.tar.gz





      share|improve this answer












      The -1 option (the digit “one”, not lower-case “L”) will list one file per line with no other information:



      ls -1 -- *.tar.gz






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered yesterday









      Stephen Kitt

      158k24351425




      158k24351425








      • 1




        Why the double dashes? ls -1 *.tar.gz works just as well.
        – RonJohn
        6 hours ago






      • 5




        @RonJohn it avoids surprises with filenames starting with -.
        – Stephen Kitt
        6 hours ago










      • Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
        – wizzwizz4
        4 hours ago
















      • 1




        Why the double dashes? ls -1 *.tar.gz works just as well.
        – RonJohn
        6 hours ago






      • 5




        @RonJohn it avoids surprises with filenames starting with -.
        – Stephen Kitt
        6 hours ago










      • Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
        – wizzwizz4
        4 hours ago










      1




      1




      Why the double dashes? ls -1 *.tar.gz works just as well.
      – RonJohn
      6 hours ago




      Why the double dashes? ls -1 *.tar.gz works just as well.
      – RonJohn
      6 hours ago




      5




      5




      @RonJohn it avoids surprises with filenames starting with -.
      – Stephen Kitt
      6 hours ago




      @RonJohn it avoids surprises with filenames starting with -.
      – Stephen Kitt
      6 hours ago












      Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
      – wizzwizz4
      4 hours ago






      Specifically... Say I was an attacker, and had the following files: .hiddenfile, benign.php, evil.bin, --hide=*evil*; without the -- you won't see evil.bin or --hide=*evil*.
      – wizzwizz4
      4 hours ago














      up vote
      15
      down vote













      If you only need the filenames, you could use printf:



      printf '%sn' *.tar.gz


      ... the shell will expand the *.tar.gz wildcard to the filenames, then printf will print them, with each followed by a newline. This output would differ a bit from that of ls in the case of filenames with newlines embedded in them:



      setup



      $ touch file{1,2}.tar.gz
      $ touch file$'n'3.tar.gz


      ls



      $ ls -1 -- *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file?3.tar.gz


      printf



      $ printf '%sn' *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file
      3.tar.gz





      share|improve this answer

















      • 6




        See also ls -b, ls -Q, ls --quoting-style=....
        – Stephen Kitt
        yesterday















      up vote
      15
      down vote













      If you only need the filenames, you could use printf:



      printf '%sn' *.tar.gz


      ... the shell will expand the *.tar.gz wildcard to the filenames, then printf will print them, with each followed by a newline. This output would differ a bit from that of ls in the case of filenames with newlines embedded in them:



      setup



      $ touch file{1,2}.tar.gz
      $ touch file$'n'3.tar.gz


      ls



      $ ls -1 -- *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file?3.tar.gz


      printf



      $ printf '%sn' *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file
      3.tar.gz





      share|improve this answer

















      • 6




        See also ls -b, ls -Q, ls --quoting-style=....
        – Stephen Kitt
        yesterday













      up vote
      15
      down vote










      up vote
      15
      down vote









      If you only need the filenames, you could use printf:



      printf '%sn' *.tar.gz


      ... the shell will expand the *.tar.gz wildcard to the filenames, then printf will print them, with each followed by a newline. This output would differ a bit from that of ls in the case of filenames with newlines embedded in them:



      setup



      $ touch file{1,2}.tar.gz
      $ touch file$'n'3.tar.gz


      ls



      $ ls -1 -- *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file?3.tar.gz


      printf



      $ printf '%sn' *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file
      3.tar.gz





      share|improve this answer












      If you only need the filenames, you could use printf:



      printf '%sn' *.tar.gz


      ... the shell will expand the *.tar.gz wildcard to the filenames, then printf will print them, with each followed by a newline. This output would differ a bit from that of ls in the case of filenames with newlines embedded in them:



      setup



      $ touch file{1,2}.tar.gz
      $ touch file$'n'3.tar.gz


      ls



      $ ls -1 -- *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file?3.tar.gz


      printf



      $ printf '%sn' *.tar.gz
      file1.tar.gz
      file2.tar.gz
      file
      3.tar.gz






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered yesterday









      Jeff Schaller

      36.8k1052121




      36.8k1052121








      • 6




        See also ls -b, ls -Q, ls --quoting-style=....
        – Stephen Kitt
        yesterday














      • 6




        See also ls -b, ls -Q, ls --quoting-style=....
        – Stephen Kitt
        yesterday








      6




      6




      See also ls -b, ls -Q, ls --quoting-style=....
      – Stephen Kitt
      yesterday




      See also ls -b, ls -Q, ls --quoting-style=....
      – Stephen Kitt
      yesterday










      up vote
      7
      down vote













      ls behaves differently when its output is piped. For example:



      ls          # outputs filenames in columns
      ls | cat # passes one filename per line to the cat command


      So if you want see all your *.tar.gz files, one per line, you can do this:



      ls *.tar.gz | cat


      But what if you don't want to pipe your output? That is, is there a way to force ls to output the filenames one to a line without piping the output?



      Yes, with the -1 switch. (That's a dash with the number 1.) So you can use these commands:



      ls -1             # shows all (non-hidden) files, one per line
      ls -1 *.tar.gz # shows only *.tar.gz files, one per line





      share|improve this answer










      New contributor




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






















        up vote
        7
        down vote













        ls behaves differently when its output is piped. For example:



        ls          # outputs filenames in columns
        ls | cat # passes one filename per line to the cat command


        So if you want see all your *.tar.gz files, one per line, you can do this:



        ls *.tar.gz | cat


        But what if you don't want to pipe your output? That is, is there a way to force ls to output the filenames one to a line without piping the output?



        Yes, with the -1 switch. (That's a dash with the number 1.) So you can use these commands:



        ls -1             # shows all (non-hidden) files, one per line
        ls -1 *.tar.gz # shows only *.tar.gz files, one per line





        share|improve this answer










        New contributor




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




















          up vote
          7
          down vote










          up vote
          7
          down vote









          ls behaves differently when its output is piped. For example:



          ls          # outputs filenames in columns
          ls | cat # passes one filename per line to the cat command


          So if you want see all your *.tar.gz files, one per line, you can do this:



          ls *.tar.gz | cat


          But what if you don't want to pipe your output? That is, is there a way to force ls to output the filenames one to a line without piping the output?



          Yes, with the -1 switch. (That's a dash with the number 1.) So you can use these commands:



          ls -1             # shows all (non-hidden) files, one per line
          ls -1 *.tar.gz # shows only *.tar.gz files, one per line





          share|improve this answer










          New contributor




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









          ls behaves differently when its output is piped. For example:



          ls          # outputs filenames in columns
          ls | cat # passes one filename per line to the cat command


          So if you want see all your *.tar.gz files, one per line, you can do this:



          ls *.tar.gz | cat


          But what if you don't want to pipe your output? That is, is there a way to force ls to output the filenames one to a line without piping the output?



          Yes, with the -1 switch. (That's a dash with the number 1.) So you can use these commands:



          ls -1             # shows all (non-hidden) files, one per line
          ls -1 *.tar.gz # shows only *.tar.gz files, one per line






          share|improve this answer










          New contributor




          J-L 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 answer



          share|improve this answer








          edited yesterday





















          New contributor




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









          answered yesterday









          J-L

          1713




          1713




          New contributor




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





          New contributor





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






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






















              up vote
              6
              down vote













              Or with GNU find:



              find  -name "*.tar.gz"  -printf '%Pn'


              In contrary to ls with * it will search for .tar.gz files recursively:



              $ find  -name "*.tar.gz"  -printf '%Pn'
              file1.tar.gz
              dir/file3.tar.gz
              file2.tar.gz





              share|improve this answer

























                up vote
                6
                down vote













                Or with GNU find:



                find  -name "*.tar.gz"  -printf '%Pn'


                In contrary to ls with * it will search for .tar.gz files recursively:



                $ find  -name "*.tar.gz"  -printf '%Pn'
                file1.tar.gz
                dir/file3.tar.gz
                file2.tar.gz





                share|improve this answer























                  up vote
                  6
                  down vote










                  up vote
                  6
                  down vote









                  Or with GNU find:



                  find  -name "*.tar.gz"  -printf '%Pn'


                  In contrary to ls with * it will search for .tar.gz files recursively:



                  $ find  -name "*.tar.gz"  -printf '%Pn'
                  file1.tar.gz
                  dir/file3.tar.gz
                  file2.tar.gz





                  share|improve this answer












                  Or with GNU find:



                  find  -name "*.tar.gz"  -printf '%Pn'


                  In contrary to ls with * it will search for .tar.gz files recursively:



                  $ find  -name "*.tar.gz"  -printf '%Pn'
                  file1.tar.gz
                  dir/file3.tar.gz
                  file2.tar.gz






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Arkadiusz Drabczyk

                  7,64521734




                  7,64521734






















                      up vote
                      3
                      down vote













                      A slightly more roundabout and loopy way:



                      for i in *.tar.gz; do
                      echo "$i"
                      done


                      EDIT: added quotes to handle weird filenames






                      share|improve this answer



















                      • 4




                        touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                        – Jeff Schaller
                        yesterday










                      • oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                        – snetch
                        yesterday






                      • 1




                        sorry! rm -- '-e a.tar.gz' should do the trick
                        – Jeff Schaller
                        yesterday










                      • You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                        – snetch
                        yesterday










                      • Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                        – Jesse Steele
                        2 hours ago















                      up vote
                      3
                      down vote













                      A slightly more roundabout and loopy way:



                      for i in *.tar.gz; do
                      echo "$i"
                      done


                      EDIT: added quotes to handle weird filenames






                      share|improve this answer



















                      • 4




                        touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                        – Jeff Schaller
                        yesterday










                      • oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                        – snetch
                        yesterday






                      • 1




                        sorry! rm -- '-e a.tar.gz' should do the trick
                        – Jeff Schaller
                        yesterday










                      • You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                        – snetch
                        yesterday










                      • Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                        – Jesse Steele
                        2 hours ago













                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote









                      A slightly more roundabout and loopy way:



                      for i in *.tar.gz; do
                      echo "$i"
                      done


                      EDIT: added quotes to handle weird filenames






                      share|improve this answer














                      A slightly more roundabout and loopy way:



                      for i in *.tar.gz; do
                      echo "$i"
                      done


                      EDIT: added quotes to handle weird filenames







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited yesterday

























                      answered yesterday









                      snetch

                      15719




                      15719








                      • 4




                        touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                        – Jeff Schaller
                        yesterday










                      • oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                        – snetch
                        yesterday






                      • 1




                        sorry! rm -- '-e a.tar.gz' should do the trick
                        – Jeff Schaller
                        yesterday










                      • You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                        – snetch
                        yesterday










                      • Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                        – Jesse Steele
                        2 hours ago














                      • 4




                        touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                        – Jeff Schaller
                        yesterday










                      • oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                        – snetch
                        yesterday






                      • 1




                        sorry! rm -- '-e a.tar.gz' should do the trick
                        – Jeff Schaller
                        yesterday










                      • You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                        – snetch
                        yesterday










                      • Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                        – Jesse Steele
                        2 hours ago








                      4




                      4




                      touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                      – Jeff Schaller
                      yesterday




                      touch -- '-e a.tar.gz' for a reason to quote your variables and unix.stackexchange.com/q/65803/117549 for reasons to use printf instead of echo
                      – Jeff Schaller
                      yesterday












                      oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                      – snetch
                      yesterday




                      oof, I just spent 5 minutes trying to figure out how to remove the resulting -e a.tar.gz file
                      – snetch
                      yesterday




                      1




                      1




                      sorry! rm -- '-e a.tar.gz' should do the trick
                      – Jeff Schaller
                      yesterday




                      sorry! rm -- '-e a.tar.gz' should do the trick
                      – Jeff Schaller
                      yesterday












                      You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                      – snetch
                      yesterday




                      You're good, it was a lesson, and I did learn that -- works for rm and a lot of others.
                      – snetch
                      yesterday












                      Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                      – Jesse Steele
                      2 hours ago




                      Thank you for that. It wouldn't be a complete question if someone didn't suggest a for-do loop to solve the problem. lol Upvoting.
                      – Jesse Steele
                      2 hours ago


















                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484481%2fhow-to-list-tar-gz-one-filename-per-line%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

                      Entries order in /etc/network/interfaces

                      新発田市

                      Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)