How to sort the output of `ls`?

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











up vote
1
down vote

favorite












alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$ ls
allTitlepage.pdf titlepage_12.pdf titlepage_19.tex titlepage_26.pdf titlepage_32.tex titlepage_4.tex
allTitlepage.tex titlepage_12.tex titlepage_1.pdf titlepage_26.tex titlepage_33.pdf titlepage_5.pdf
assignment.pdf titlepage_13.pdf titlepage_1.tex titlepage_27.pdf titlepage_34.pdf titlepage_5.tex
assignment.tex titlepage_13.tex titlepage_20.pdf titlepage_27.tex titlepage_34.tex titlepage_6.pdf
graphicsAssignment2.pdf titlepage_14.pdf titlepage_20.tex titlepage_28.pdf titlepage_35.pdf titlepage_6.tex
graphicsAssignment2.tex titlepage_14.tex titlepage_21.pdf titlepage_28.tex titlepage_35.tex titlepage_7.pdf
README.md titlepage_15.pdf titlepage_21.tex titlepage_29.pdf titlepage_36.pdf titlepage_7.tex
thesisTitlepage.pdf titlepage_15.tex titlepage_22.pdf titlepage_29.tex titlepage_36.tex titlepage_8.pdf
thesisTitlepage.tex titlepage_16.pdf titlepage_22.tex titlepage_2.pdf titlepage_37.pdf titlepage_8.tex
titlepage_0.pdf titlepage_16.tex titlepage_23.pdf titlepage_2.tex titlepage_37.tex titlepage_9.pdf
titlepage_0.tex titlepage_17.pdf titlepage_23.tex titlepage_30.pdf titlepage_38.pdf titlepage_9.tex
titlepage_10.pdf titlepage_17.tex titlepage_24.pdf titlepage_30.tex titlepage_38.tex titlepage_one.pdf
titlepage_10.tex titlepage_18.pdf titlepage_24.tex titlepage_31.pdf titlepage_3.pdf titlepage_one.tex
titlepage_11.pdf titlepage_18.tex titlepage_25.pdf titlepage_31.tex titlepage_3.tex titlepage_two.tex
titlepage_11.tex titlepage_19.pdf titlepage_25.tex titlepage_32.pdf titlepage_4.pdf
alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$


Is it possible to view the output with sorted(titlepage_1.pdf should before of titlepage_19.pdf).










share|improve this question

























    up vote
    1
    down vote

    favorite












    alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$ ls
    allTitlepage.pdf titlepage_12.pdf titlepage_19.tex titlepage_26.pdf titlepage_32.tex titlepage_4.tex
    allTitlepage.tex titlepage_12.tex titlepage_1.pdf titlepage_26.tex titlepage_33.pdf titlepage_5.pdf
    assignment.pdf titlepage_13.pdf titlepage_1.tex titlepage_27.pdf titlepage_34.pdf titlepage_5.tex
    assignment.tex titlepage_13.tex titlepage_20.pdf titlepage_27.tex titlepage_34.tex titlepage_6.pdf
    graphicsAssignment2.pdf titlepage_14.pdf titlepage_20.tex titlepage_28.pdf titlepage_35.pdf titlepage_6.tex
    graphicsAssignment2.tex titlepage_14.tex titlepage_21.pdf titlepage_28.tex titlepage_35.tex titlepage_7.pdf
    README.md titlepage_15.pdf titlepage_21.tex titlepage_29.pdf titlepage_36.pdf titlepage_7.tex
    thesisTitlepage.pdf titlepage_15.tex titlepage_22.pdf titlepage_29.tex titlepage_36.tex titlepage_8.pdf
    thesisTitlepage.tex titlepage_16.pdf titlepage_22.tex titlepage_2.pdf titlepage_37.pdf titlepage_8.tex
    titlepage_0.pdf titlepage_16.tex titlepage_23.pdf titlepage_2.tex titlepage_37.tex titlepage_9.pdf
    titlepage_0.tex titlepage_17.pdf titlepage_23.tex titlepage_30.pdf titlepage_38.pdf titlepage_9.tex
    titlepage_10.pdf titlepage_17.tex titlepage_24.pdf titlepage_30.tex titlepage_38.tex titlepage_one.pdf
    titlepage_10.tex titlepage_18.pdf titlepage_24.tex titlepage_31.pdf titlepage_3.pdf titlepage_one.tex
    titlepage_11.pdf titlepage_18.tex titlepage_25.pdf titlepage_31.tex titlepage_3.tex titlepage_two.tex
    titlepage_11.tex titlepage_19.pdf titlepage_25.tex titlepage_32.pdf titlepage_4.pdf
    alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$


    Is it possible to view the output with sorted(titlepage_1.pdf should before of titlepage_19.pdf).










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$ ls
      allTitlepage.pdf titlepage_12.pdf titlepage_19.tex titlepage_26.pdf titlepage_32.tex titlepage_4.tex
      allTitlepage.tex titlepage_12.tex titlepage_1.pdf titlepage_26.tex titlepage_33.pdf titlepage_5.pdf
      assignment.pdf titlepage_13.pdf titlepage_1.tex titlepage_27.pdf titlepage_34.pdf titlepage_5.tex
      assignment.tex titlepage_13.tex titlepage_20.pdf titlepage_27.tex titlepage_34.tex titlepage_6.pdf
      graphicsAssignment2.pdf titlepage_14.pdf titlepage_20.tex titlepage_28.pdf titlepage_35.pdf titlepage_6.tex
      graphicsAssignment2.tex titlepage_14.tex titlepage_21.pdf titlepage_28.tex titlepage_35.tex titlepage_7.pdf
      README.md titlepage_15.pdf titlepage_21.tex titlepage_29.pdf titlepage_36.pdf titlepage_7.tex
      thesisTitlepage.pdf titlepage_15.tex titlepage_22.pdf titlepage_29.tex titlepage_36.tex titlepage_8.pdf
      thesisTitlepage.tex titlepage_16.pdf titlepage_22.tex titlepage_2.pdf titlepage_37.pdf titlepage_8.tex
      titlepage_0.pdf titlepage_16.tex titlepage_23.pdf titlepage_2.tex titlepage_37.tex titlepage_9.pdf
      titlepage_0.tex titlepage_17.pdf titlepage_23.tex titlepage_30.pdf titlepage_38.pdf titlepage_9.tex
      titlepage_10.pdf titlepage_17.tex titlepage_24.pdf titlepage_30.tex titlepage_38.tex titlepage_one.pdf
      titlepage_10.tex titlepage_18.pdf titlepage_24.tex titlepage_31.pdf titlepage_3.pdf titlepage_one.tex
      titlepage_11.pdf titlepage_18.tex titlepage_25.pdf titlepage_31.tex titlepage_3.tex titlepage_two.tex
      titlepage_11.tex titlepage_19.pdf titlepage_25.tex titlepage_32.pdf titlepage_4.pdf
      alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$


      Is it possible to view the output with sorted(titlepage_1.pdf should before of titlepage_19.pdf).










      share|improve this question













      alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$ ls
      allTitlepage.pdf titlepage_12.pdf titlepage_19.tex titlepage_26.pdf titlepage_32.tex titlepage_4.tex
      allTitlepage.tex titlepage_12.tex titlepage_1.pdf titlepage_26.tex titlepage_33.pdf titlepage_5.pdf
      assignment.pdf titlepage_13.pdf titlepage_1.tex titlepage_27.pdf titlepage_34.pdf titlepage_5.tex
      assignment.tex titlepage_13.tex titlepage_20.pdf titlepage_27.tex titlepage_34.tex titlepage_6.pdf
      graphicsAssignment2.pdf titlepage_14.pdf titlepage_20.tex titlepage_28.pdf titlepage_35.pdf titlepage_6.tex
      graphicsAssignment2.tex titlepage_14.tex titlepage_21.pdf titlepage_28.tex titlepage_35.tex titlepage_7.pdf
      README.md titlepage_15.pdf titlepage_21.tex titlepage_29.pdf titlepage_36.pdf titlepage_7.tex
      thesisTitlepage.pdf titlepage_15.tex titlepage_22.pdf titlepage_29.tex titlepage_36.tex titlepage_8.pdf
      thesisTitlepage.tex titlepage_16.pdf titlepage_22.tex titlepage_2.pdf titlepage_37.pdf titlepage_8.tex
      titlepage_0.pdf titlepage_16.tex titlepage_23.pdf titlepage_2.tex titlepage_37.tex titlepage_9.pdf
      titlepage_0.tex titlepage_17.pdf titlepage_23.tex titlepage_30.pdf titlepage_38.pdf titlepage_9.tex
      titlepage_10.pdf titlepage_17.tex titlepage_24.pdf titlepage_30.tex titlepage_38.tex titlepage_one.pdf
      titlepage_10.tex titlepage_18.pdf titlepage_24.tex titlepage_31.pdf titlepage_3.pdf titlepage_one.tex
      titlepage_11.pdf titlepage_18.tex titlepage_25.pdf titlepage_31.tex titlepage_3.tex titlepage_two.tex
      titlepage_11.tex titlepage_19.pdf titlepage_25.tex titlepage_32.pdf titlepage_4.pdf
      alhelal@VimLaTeX:~/Dropbox/Apps/Overleaf/Titlepage$


      Is it possible to view the output with sorted(titlepage_1.pdf should before of titlepage_19.pdf).







      ls






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 47 mins ago









      alhelal

      5652625




      5652625




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          4
          down vote













          Use the option -v (natural sort of (version) numbers within text)



          ls -v





          share|improve this answer



























            up vote
            1
            down vote













            The output is sorted. According to the sort manpage:




            Sort entries alphabetically if none of -cftuvSUX nor --sort is
            specified.




            But if you want to go further, you have at least two options:



            1. man ls tells you about a number of switches you can use to sort, specifically, the ls man page says: 'none (-U), size (-S), time (-t), version (-v), extension (-X)'


            2. You could use a pipe | to send the output to another command, for example the command sort which you could use to sort in a number of other ways, as in ls -1 | sort -n which is useful if you have numbered files.


            Equally, you can manipulate the output to aid with sorting by using things like sed or awk.



            There are plenty of ways to answer this sort of* question. You may find a linux shell tutorial helpful.



            *(See what I did there? :-p)






            share|improve this answer



























              up vote
              1
              down vote













              As already pointed out in a comment, the output is already sorted, but by characters, not numbers.
              You may want to pipe the output of ls through sort which has a switch to sort by numbers within strings:



              ls | sort --version-sort


              From the manpage:




              -V, --version-sort
              natural sort of (version) numbers within text



              Downside: When we issue ls then it outputs the files in a table with as many columns as fit on the current screen (just like you showed in your post). But when ls notices that its output is redirected to a file or to a pipe (as in ls | sort) then ls prints the files in just one column because it then assumes the output is to be processed line-by-line (aka file-by-file) by some other program (like sort). So the output of ls | sort -V will be in one column instead of in a table with multiple columns. See @vijay's simple but perfect answer for how to avoid that.






              share|improve this answer






















                Your Answer







                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "89"
                ;
                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
                );



                );













                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1081689%2fhow-to-sort-the-output-of-ls%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                4
                down vote













                Use the option -v (natural sort of (version) numbers within text)



                ls -v





                share|improve this answer
























                  up vote
                  4
                  down vote













                  Use the option -v (natural sort of (version) numbers within text)



                  ls -v





                  share|improve this answer






















                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    Use the option -v (natural sort of (version) numbers within text)



                    ls -v





                    share|improve this answer












                    Use the option -v (natural sort of (version) numbers within text)



                    ls -v






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 29 mins ago









                    Vijay

                    192113




                    192113






















                        up vote
                        1
                        down vote













                        The output is sorted. According to the sort manpage:




                        Sort entries alphabetically if none of -cftuvSUX nor --sort is
                        specified.




                        But if you want to go further, you have at least two options:



                        1. man ls tells you about a number of switches you can use to sort, specifically, the ls man page says: 'none (-U), size (-S), time (-t), version (-v), extension (-X)'


                        2. You could use a pipe | to send the output to another command, for example the command sort which you could use to sort in a number of other ways, as in ls -1 | sort -n which is useful if you have numbered files.


                        Equally, you can manipulate the output to aid with sorting by using things like sed or awk.



                        There are plenty of ways to answer this sort of* question. You may find a linux shell tutorial helpful.



                        *(See what I did there? :-p)






                        share|improve this answer
























                          up vote
                          1
                          down vote













                          The output is sorted. According to the sort manpage:




                          Sort entries alphabetically if none of -cftuvSUX nor --sort is
                          specified.




                          But if you want to go further, you have at least two options:



                          1. man ls tells you about a number of switches you can use to sort, specifically, the ls man page says: 'none (-U), size (-S), time (-t), version (-v), extension (-X)'


                          2. You could use a pipe | to send the output to another command, for example the command sort which you could use to sort in a number of other ways, as in ls -1 | sort -n which is useful if you have numbered files.


                          Equally, you can manipulate the output to aid with sorting by using things like sed or awk.



                          There are plenty of ways to answer this sort of* question. You may find a linux shell tutorial helpful.



                          *(See what I did there? :-p)






                          share|improve this answer






















                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            The output is sorted. According to the sort manpage:




                            Sort entries alphabetically if none of -cftuvSUX nor --sort is
                            specified.




                            But if you want to go further, you have at least two options:



                            1. man ls tells you about a number of switches you can use to sort, specifically, the ls man page says: 'none (-U), size (-S), time (-t), version (-v), extension (-X)'


                            2. You could use a pipe | to send the output to another command, for example the command sort which you could use to sort in a number of other ways, as in ls -1 | sort -n which is useful if you have numbered files.


                            Equally, you can manipulate the output to aid with sorting by using things like sed or awk.



                            There are plenty of ways to answer this sort of* question. You may find a linux shell tutorial helpful.



                            *(See what I did there? :-p)






                            share|improve this answer












                            The output is sorted. According to the sort manpage:




                            Sort entries alphabetically if none of -cftuvSUX nor --sort is
                            specified.




                            But if you want to go further, you have at least two options:



                            1. man ls tells you about a number of switches you can use to sort, specifically, the ls man page says: 'none (-U), size (-S), time (-t), version (-v), extension (-X)'


                            2. You could use a pipe | to send the output to another command, for example the command sort which you could use to sort in a number of other ways, as in ls -1 | sort -n which is useful if you have numbered files.


                            Equally, you can manipulate the output to aid with sorting by using things like sed or awk.



                            There are plenty of ways to answer this sort of* question. You may find a linux shell tutorial helpful.



                            *(See what I did there? :-p)







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 30 mins ago









                            tudor

                            1,26521440




                            1,26521440




















                                up vote
                                1
                                down vote













                                As already pointed out in a comment, the output is already sorted, but by characters, not numbers.
                                You may want to pipe the output of ls through sort which has a switch to sort by numbers within strings:



                                ls | sort --version-sort


                                From the manpage:




                                -V, --version-sort
                                natural sort of (version) numbers within text



                                Downside: When we issue ls then it outputs the files in a table with as many columns as fit on the current screen (just like you showed in your post). But when ls notices that its output is redirected to a file or to a pipe (as in ls | sort) then ls prints the files in just one column because it then assumes the output is to be processed line-by-line (aka file-by-file) by some other program (like sort). So the output of ls | sort -V will be in one column instead of in a table with multiple columns. See @vijay's simple but perfect answer for how to avoid that.






                                share|improve this answer


























                                  up vote
                                  1
                                  down vote













                                  As already pointed out in a comment, the output is already sorted, but by characters, not numbers.
                                  You may want to pipe the output of ls through sort which has a switch to sort by numbers within strings:



                                  ls | sort --version-sort


                                  From the manpage:




                                  -V, --version-sort
                                  natural sort of (version) numbers within text



                                  Downside: When we issue ls then it outputs the files in a table with as many columns as fit on the current screen (just like you showed in your post). But when ls notices that its output is redirected to a file or to a pipe (as in ls | sort) then ls prints the files in just one column because it then assumes the output is to be processed line-by-line (aka file-by-file) by some other program (like sort). So the output of ls | sort -V will be in one column instead of in a table with multiple columns. See @vijay's simple but perfect answer for how to avoid that.






                                  share|improve this answer
























                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    As already pointed out in a comment, the output is already sorted, but by characters, not numbers.
                                    You may want to pipe the output of ls through sort which has a switch to sort by numbers within strings:



                                    ls | sort --version-sort


                                    From the manpage:




                                    -V, --version-sort
                                    natural sort of (version) numbers within text



                                    Downside: When we issue ls then it outputs the files in a table with as many columns as fit on the current screen (just like you showed in your post). But when ls notices that its output is redirected to a file or to a pipe (as in ls | sort) then ls prints the files in just one column because it then assumes the output is to be processed line-by-line (aka file-by-file) by some other program (like sort). So the output of ls | sort -V will be in one column instead of in a table with multiple columns. See @vijay's simple but perfect answer for how to avoid that.






                                    share|improve this answer














                                    As already pointed out in a comment, the output is already sorted, but by characters, not numbers.
                                    You may want to pipe the output of ls through sort which has a switch to sort by numbers within strings:



                                    ls | sort --version-sort


                                    From the manpage:




                                    -V, --version-sort
                                    natural sort of (version) numbers within text



                                    Downside: When we issue ls then it outputs the files in a table with as many columns as fit on the current screen (just like you showed in your post). But when ls notices that its output is redirected to a file or to a pipe (as in ls | sort) then ls prints the files in just one column because it then assumes the output is to be processed line-by-line (aka file-by-file) by some other program (like sort). So the output of ls | sort -V will be in one column instead of in a table with multiple columns. See @vijay's simple but perfect answer for how to avoid that.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 1 min ago

























                                    answered 26 mins ago









                                    PerlDuck

                                    4,11211030




                                    4,11211030



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1081689%2fhow-to-sort-the-output-of-ls%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Comments

                                        Popular posts from this blog

                                        What does second last employer means? [closed]

                                        List of Gilmore Girls characters

                                        Confectionery