How do I show all the files in a directory with a name containing a number?

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











up vote
1
down vote

favorite












How do I show all the files in a directory with a name contain a number? I tried



ls [0-9] textfiles


(textfiles) is my directory.



This is how my Linux pocket guide shows me. I am just trying to display all the files that contain a number in the name. I have actually tried about 20+ variations that I found in my book and online.










share|improve this question









New contributor




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























    up vote
    1
    down vote

    favorite












    How do I show all the files in a directory with a name contain a number? I tried



    ls [0-9] textfiles


    (textfiles) is my directory.



    This is how my Linux pocket guide shows me. I am just trying to display all the files that contain a number in the name. I have actually tried about 20+ variations that I found in my book and online.










    share|improve this question









    New contributor




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





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      How do I show all the files in a directory with a name contain a number? I tried



      ls [0-9] textfiles


      (textfiles) is my directory.



      This is how my Linux pocket guide shows me. I am just trying to display all the files that contain a number in the name. I have actually tried about 20+ variations that I found in my book and online.










      share|improve this question









      New contributor




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











      How do I show all the files in a directory with a name contain a number? I tried



      ls [0-9] textfiles


      (textfiles) is my directory.



      This is how my Linux pocket guide shows me. I am just trying to display all the files that contain a number in the name. I have actually tried about 20+ variations that I found in my book and online.







      linux ls






      share|improve this question









      New contributor




      StPatrick 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




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









      fixer1234

      16.9k144176




      16.9k144176






      New contributor




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









      asked 4 hours ago









      StPatrick

      61




      61




      New contributor




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





      New contributor





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






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




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          You probably want something like



          ls textfiles/*[0-9]*


          or (if "textfiles is my directory" means you're inside the directory):



          ls *[0-9]*


          Note these commands don't restrict themselves to regular files. Directories, symlinks, named pipes and other entries may match. In broad Unix context all these are "files" and such matching is done with respect to their names only. To tell regular files apart, you need another tool like find.



          I'm surprised any guide advised you ls [0-9] textfiles as it makes little sense in the context of your question.



          To decode *[0-9]* refer to man 7 glob or e.g. this article, Standard Wildcards (globbing patterns) section. It's worth noticing in the above cases it's the shell (not ls!) that expands the given pattern.






          share|improve this answer






















          • Thank you. This worked great.
            – StPatrick
            3 hours ago










          • @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
            – Kamil Maciorowski
            3 hours ago

















          up vote
          0
          down vote













          Find also works, and can display only files, for example in the current dir (.)



          find . -type f -name *[0-9]*


          It's recursive by default.





          share




















            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',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            StPatrick 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%2f1369028%2fhow-do-i-show-all-the-files-in-a-directory-with-a-name-containing-a-number%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote













            You probably want something like



            ls textfiles/*[0-9]*


            or (if "textfiles is my directory" means you're inside the directory):



            ls *[0-9]*


            Note these commands don't restrict themselves to regular files. Directories, symlinks, named pipes and other entries may match. In broad Unix context all these are "files" and such matching is done with respect to their names only. To tell regular files apart, you need another tool like find.



            I'm surprised any guide advised you ls [0-9] textfiles as it makes little sense in the context of your question.



            To decode *[0-9]* refer to man 7 glob or e.g. this article, Standard Wildcards (globbing patterns) section. It's worth noticing in the above cases it's the shell (not ls!) that expands the given pattern.






            share|improve this answer






















            • Thank you. This worked great.
              – StPatrick
              3 hours ago










            • @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
              – Kamil Maciorowski
              3 hours ago














            up vote
            4
            down vote













            You probably want something like



            ls textfiles/*[0-9]*


            or (if "textfiles is my directory" means you're inside the directory):



            ls *[0-9]*


            Note these commands don't restrict themselves to regular files. Directories, symlinks, named pipes and other entries may match. In broad Unix context all these are "files" and such matching is done with respect to their names only. To tell regular files apart, you need another tool like find.



            I'm surprised any guide advised you ls [0-9] textfiles as it makes little sense in the context of your question.



            To decode *[0-9]* refer to man 7 glob or e.g. this article, Standard Wildcards (globbing patterns) section. It's worth noticing in the above cases it's the shell (not ls!) that expands the given pattern.






            share|improve this answer






















            • Thank you. This worked great.
              – StPatrick
              3 hours ago










            • @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
              – Kamil Maciorowski
              3 hours ago












            up vote
            4
            down vote










            up vote
            4
            down vote









            You probably want something like



            ls textfiles/*[0-9]*


            or (if "textfiles is my directory" means you're inside the directory):



            ls *[0-9]*


            Note these commands don't restrict themselves to regular files. Directories, symlinks, named pipes and other entries may match. In broad Unix context all these are "files" and such matching is done with respect to their names only. To tell regular files apart, you need another tool like find.



            I'm surprised any guide advised you ls [0-9] textfiles as it makes little sense in the context of your question.



            To decode *[0-9]* refer to man 7 glob or e.g. this article, Standard Wildcards (globbing patterns) section. It's worth noticing in the above cases it's the shell (not ls!) that expands the given pattern.






            share|improve this answer














            You probably want something like



            ls textfiles/*[0-9]*


            or (if "textfiles is my directory" means you're inside the directory):



            ls *[0-9]*


            Note these commands don't restrict themselves to regular files. Directories, symlinks, named pipes and other entries may match. In broad Unix context all these are "files" and such matching is done with respect to their names only. To tell regular files apart, you need another tool like find.



            I'm surprised any guide advised you ls [0-9] textfiles as it makes little sense in the context of your question.



            To decode *[0-9]* refer to man 7 glob or e.g. this article, Standard Wildcards (globbing patterns) section. It's worth noticing in the above cases it's the shell (not ls!) that expands the given pattern.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 3 hours ago

























            answered 3 hours ago









            Kamil Maciorowski

            21.8k155072




            21.8k155072











            • Thank you. This worked great.
              – StPatrick
              3 hours ago










            • @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
              – Kamil Maciorowski
              3 hours ago
















            • Thank you. This worked great.
              – StPatrick
              3 hours ago










            • @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
              – Kamil Maciorowski
              3 hours ago















            Thank you. This worked great.
            – StPatrick
            3 hours ago




            Thank you. This worked great.
            – StPatrick
            3 hours ago












            @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
            – Kamil Maciorowski
            3 hours ago




            @StPatrick Please take our quick tour to learn what you can do with an answer that solves your problem.
            – Kamil Maciorowski
            3 hours ago












            up vote
            0
            down vote













            Find also works, and can display only files, for example in the current dir (.)



            find . -type f -name *[0-9]*


            It's recursive by default.





            share
























              up vote
              0
              down vote













              Find also works, and can display only files, for example in the current dir (.)



              find . -type f -name *[0-9]*


              It's recursive by default.





              share






















                up vote
                0
                down vote










                up vote
                0
                down vote









                Find also works, and can display only files, for example in the current dir (.)



                find . -type f -name *[0-9]*


                It's recursive by default.





                share












                Find also works, and can display only files, for example in the current dir (.)



                find . -type f -name *[0-9]*


                It's recursive by default.






                share











                share


                share










                answered 8 mins ago









                Xen2050

                9,47931536




                9,47931536




















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









                     

                    draft saved


                    draft discarded


















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












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











                    StPatrick 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%2f1369028%2fhow-do-i-show-all-the-files-in-a-directory-with-a-name-containing-a-number%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke