how do I display file names that contain two characters and one of them is c?

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











up vote
2
down vote

favorite












I tried doing ls [a-z][a-z] but it doesn't seem to be working.










share|improve this question



























    up vote
    2
    down vote

    favorite












    I tried doing ls [a-z][a-z] but it doesn't seem to be working.










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I tried doing ls [a-z][a-z] but it doesn't seem to be working.










      share|improve this question















      I tried doing ls [a-z][a-z] but it doesn't seem to be working.







      linux bash shell filenames command






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 25 mins ago









      Jeff Schaller

      33.5k850112




      33.5k850112










      asked 30 mins ago









      amendeep singh

      233




      233




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          With bash, set the glob settings so that missing matches don't trigger an error:



          shopt -u failglob # missing matches are just dropped
          shopt -s nullglob # missing matches don't report a failure
          ls ?c c?


          Question-mark is a glob character representing a single character. Since you want two-character filenames, one of them has to be a c, and so it's either the first character or the last character.



          With shopt -s dotglob this would also surface a file named .c.



          If there are no matching files, setting these shell options causes all of the arguments to be removed, resulting in a bare ls -- listing anything/everything by default.



          Use this, instead:



          shopt -s nullglob ## drop any missing globs
          set -- ?c c? ## populate the $@ array with (any) matches
          if [ $# -gt 0 ] ## if there are some, list them
          ls -d "$@"
          fi





          share|improve this answer






















          • You may also want to use nullglob?
            – Kusalananda
            19 mins ago










          • and failglob; thanks, @Kusalananda!
            – Jeff Schaller
            16 mins ago










          • thanks that was what i needed
            – amendeep singh
            15 mins ago










          • erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
            – Jeff Schaller
            15 mins ago

















          up vote
          3
          down vote













          Try this



          ls -d c?


          or



          ls -d ?c


          Use the ? wildcard for file globbing, it represent the number of characters you want to search for. Change c position whether at beginning or at end.



          The -d flag will prevent ls displaying the content of subdirectories that match the pattern.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            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%2f473511%2fhow-do-i-display-file-names-that-contain-two-characters-and-one-of-them-is-c%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
            6
            down vote



            accepted










            With bash, set the glob settings so that missing matches don't trigger an error:



            shopt -u failglob # missing matches are just dropped
            shopt -s nullglob # missing matches don't report a failure
            ls ?c c?


            Question-mark is a glob character representing a single character. Since you want two-character filenames, one of them has to be a c, and so it's either the first character or the last character.



            With shopt -s dotglob this would also surface a file named .c.



            If there are no matching files, setting these shell options causes all of the arguments to be removed, resulting in a bare ls -- listing anything/everything by default.



            Use this, instead:



            shopt -s nullglob ## drop any missing globs
            set -- ?c c? ## populate the $@ array with (any) matches
            if [ $# -gt 0 ] ## if there are some, list them
            ls -d "$@"
            fi





            share|improve this answer






















            • You may also want to use nullglob?
              – Kusalananda
              19 mins ago










            • and failglob; thanks, @Kusalananda!
              – Jeff Schaller
              16 mins ago










            • thanks that was what i needed
              – amendeep singh
              15 mins ago










            • erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
              – Jeff Schaller
              15 mins ago














            up vote
            6
            down vote



            accepted










            With bash, set the glob settings so that missing matches don't trigger an error:



            shopt -u failglob # missing matches are just dropped
            shopt -s nullglob # missing matches don't report a failure
            ls ?c c?


            Question-mark is a glob character representing a single character. Since you want two-character filenames, one of them has to be a c, and so it's either the first character or the last character.



            With shopt -s dotglob this would also surface a file named .c.



            If there are no matching files, setting these shell options causes all of the arguments to be removed, resulting in a bare ls -- listing anything/everything by default.



            Use this, instead:



            shopt -s nullglob ## drop any missing globs
            set -- ?c c? ## populate the $@ array with (any) matches
            if [ $# -gt 0 ] ## if there are some, list them
            ls -d "$@"
            fi





            share|improve this answer






















            • You may also want to use nullglob?
              – Kusalananda
              19 mins ago










            • and failglob; thanks, @Kusalananda!
              – Jeff Schaller
              16 mins ago










            • thanks that was what i needed
              – amendeep singh
              15 mins ago










            • erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
              – Jeff Schaller
              15 mins ago












            up vote
            6
            down vote



            accepted







            up vote
            6
            down vote



            accepted






            With bash, set the glob settings so that missing matches don't trigger an error:



            shopt -u failglob # missing matches are just dropped
            shopt -s nullglob # missing matches don't report a failure
            ls ?c c?


            Question-mark is a glob character representing a single character. Since you want two-character filenames, one of them has to be a c, and so it's either the first character or the last character.



            With shopt -s dotglob this would also surface a file named .c.



            If there are no matching files, setting these shell options causes all of the arguments to be removed, resulting in a bare ls -- listing anything/everything by default.



            Use this, instead:



            shopt -s nullglob ## drop any missing globs
            set -- ?c c? ## populate the $@ array with (any) matches
            if [ $# -gt 0 ] ## if there are some, list them
            ls -d "$@"
            fi





            share|improve this answer














            With bash, set the glob settings so that missing matches don't trigger an error:



            shopt -u failglob # missing matches are just dropped
            shopt -s nullglob # missing matches don't report a failure
            ls ?c c?


            Question-mark is a glob character representing a single character. Since you want two-character filenames, one of them has to be a c, and so it's either the first character or the last character.



            With shopt -s dotglob this would also surface a file named .c.



            If there are no matching files, setting these shell options causes all of the arguments to be removed, resulting in a bare ls -- listing anything/everything by default.



            Use this, instead:



            shopt -s nullglob ## drop any missing globs
            set -- ?c c? ## populate the $@ array with (any) matches
            if [ $# -gt 0 ] ## if there are some, list them
            ls -d "$@"
            fi






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 10 mins ago

























            answered 23 mins ago









            Jeff Schaller

            33.5k850112




            33.5k850112











            • You may also want to use nullglob?
              – Kusalananda
              19 mins ago










            • and failglob; thanks, @Kusalananda!
              – Jeff Schaller
              16 mins ago










            • thanks that was what i needed
              – amendeep singh
              15 mins ago










            • erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
              – Jeff Schaller
              15 mins ago
















            • You may also want to use nullglob?
              – Kusalananda
              19 mins ago










            • and failglob; thanks, @Kusalananda!
              – Jeff Schaller
              16 mins ago










            • thanks that was what i needed
              – amendeep singh
              15 mins ago










            • erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
              – Jeff Schaller
              15 mins ago















            You may also want to use nullglob?
            – Kusalananda
            19 mins ago




            You may also want to use nullglob?
            – Kusalananda
            19 mins ago












            and failglob; thanks, @Kusalananda!
            – Jeff Schaller
            16 mins ago




            and failglob; thanks, @Kusalananda!
            – Jeff Schaller
            16 mins ago












            thanks that was what i needed
            – amendeep singh
            15 mins ago




            thanks that was what i needed
            – amendeep singh
            15 mins ago












            erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
            – Jeff Schaller
            15 mins ago




            erm, not quite -- failglob removes the error but also removes everything (thus listing everything) if there are no matches
            – Jeff Schaller
            15 mins ago












            up vote
            3
            down vote













            Try this



            ls -d c?


            or



            ls -d ?c


            Use the ? wildcard for file globbing, it represent the number of characters you want to search for. Change c position whether at beginning or at end.



            The -d flag will prevent ls displaying the content of subdirectories that match the pattern.






            share|improve this answer
























              up vote
              3
              down vote













              Try this



              ls -d c?


              or



              ls -d ?c


              Use the ? wildcard for file globbing, it represent the number of characters you want to search for. Change c position whether at beginning or at end.



              The -d flag will prevent ls displaying the content of subdirectories that match the pattern.






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                Try this



                ls -d c?


                or



                ls -d ?c


                Use the ? wildcard for file globbing, it represent the number of characters you want to search for. Change c position whether at beginning or at end.



                The -d flag will prevent ls displaying the content of subdirectories that match the pattern.






                share|improve this answer












                Try this



                ls -d c?


                or



                ls -d ?c


                Use the ? wildcard for file globbing, it represent the number of characters you want to search for. Change c position whether at beginning or at end.



                The -d flag will prevent ls displaying the content of subdirectories that match the pattern.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 23 mins ago









                Goro

                6,61052865




                6,61052865



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473511%2fhow-do-i-display-file-names-that-contain-two-characters-and-one-of-them-is-c%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