What does the “ls -1” command do?

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite
1












In my current directory, I execute the command:
ls -1 and it gives a list of the current directory contents.



In the same directory, I repeat the command: ls and it gives me the same result, with perhaps a different formatted output.



Finally, I try to find out about the available commands by typing ls --help and the output is:



usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]


It looks like the last option is 1 (#1). Can someone explain what the ls -1 does and how it's different to the standard ls command?







share|improve this question

















  • 1




    Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
    – JdeBP
    Jul 19 at 13:45






  • 1




    check if your ls command is also aliased
    – ron
    Jul 19 at 13:56










  • I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
    – ron
    Jul 19 at 14:03







  • 1




    ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
    – Mark Stewart
    Jul 19 at 14:20






  • 2




    @Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
    – Stephen Kitt
    Jul 19 at 17:55
















up vote
2
down vote

favorite
1












In my current directory, I execute the command:
ls -1 and it gives a list of the current directory contents.



In the same directory, I repeat the command: ls and it gives me the same result, with perhaps a different formatted output.



Finally, I try to find out about the available commands by typing ls --help and the output is:



usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]


It looks like the last option is 1 (#1). Can someone explain what the ls -1 does and how it's different to the standard ls command?







share|improve this question

















  • 1




    Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
    – JdeBP
    Jul 19 at 13:45






  • 1




    check if your ls command is also aliased
    – ron
    Jul 19 at 13:56










  • I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
    – ron
    Jul 19 at 14:03







  • 1




    ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
    – Mark Stewart
    Jul 19 at 14:20






  • 2




    @Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
    – Stephen Kitt
    Jul 19 at 17:55












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





In my current directory, I execute the command:
ls -1 and it gives a list of the current directory contents.



In the same directory, I repeat the command: ls and it gives me the same result, with perhaps a different formatted output.



Finally, I try to find out about the available commands by typing ls --help and the output is:



usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]


It looks like the last option is 1 (#1). Can someone explain what the ls -1 does and how it's different to the standard ls command?







share|improve this question













In my current directory, I execute the command:
ls -1 and it gives a list of the current directory contents.



In the same directory, I repeat the command: ls and it gives me the same result, with perhaps a different formatted output.



Finally, I try to find out about the available commands by typing ls --help and the output is:



usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]


It looks like the last option is 1 (#1). Can someone explain what the ls -1 does and how it's different to the standard ls command?









share|improve this question












share|improve this question




share|improve this question








edited Jul 19 at 13:59









Kusalananda

101k13199311




101k13199311









asked Jul 19 at 13:37









James Peter McConnell

194




194







  • 1




    Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
    – JdeBP
    Jul 19 at 13:45






  • 1




    check if your ls command is also aliased
    – ron
    Jul 19 at 13:56










  • I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
    – ron
    Jul 19 at 14:03







  • 1




    ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
    – Mark Stewart
    Jul 19 at 14:20






  • 2




    @Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
    – Stephen Kitt
    Jul 19 at 17:55












  • 1




    Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
    – JdeBP
    Jul 19 at 13:45






  • 1




    check if your ls command is also aliased
    – ron
    Jul 19 at 13:56










  • I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
    – ron
    Jul 19 at 14:03







  • 1




    ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
    – Mark Stewart
    Jul 19 at 14:20






  • 2




    @Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
    – Stephen Kitt
    Jul 19 at 17:55







1




1




Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
– JdeBP
Jul 19 at 13:45




Related questions are unix.stackexchange.com/questions/410550 , unix.stackexchange.com/questions/112125 , and unix.stackexchange.com/questions/111975 .
– JdeBP
Jul 19 at 13:45




1




1




check if your ls command is also aliased
– ron
Jul 19 at 13:56




check if your ls command is also aliased
– ron
Jul 19 at 13:56












I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
– ron
Jul 19 at 14:03





I know Suse aliasies ls in /etc/bash.bashrc for example, and also has an environment variable "LS_OPTIONS" and they use some options I do not care for so I manually comment out any aliasing of the ls command; if this is happening under the hood on you without you knowing then ls output can sometimes not make sense and be confusing (i.e. why is this happening) ls -1 should simply output one column but only if some other option is not overriding or preventing it from happening
– ron
Jul 19 at 14:03





1




1




ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
– Mark Stewart
Jul 19 at 14:20




ls -1 is often used by shell scripts to ensure there is minimal information and one file per line to make processing file names easy.
– Mark Stewart
Jul 19 at 14:20




2




2




@Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
– Stephen Kitt
Jul 19 at 17:55




@Mark indeed, but parsing ls is a bad idea, and ls -1 is the default when the output isn’t a terminal (which is the case when the output is supposed to be processed in a script).
– Stephen Kitt
Jul 19 at 17:55










3 Answers
3






active

oldest

votes

















up vote
17
down vote



accepted










Yes, the formatting of the output is the only difference between ls -1 and ls without any options.



From the ls manual on my system:



 -1 (The numeric digit "one".) Force output to be one entry per line.
This is the default when output is not to a terminal.


This is also a POSIX option to the ls utility.



The manual for ls on your system is bound to say something similar (see man ls).



Related:



  • is piped ls the same as ls -1?





share|improve this answer






























    up vote
    9
    down vote













    ls -1 lists one file per line. By default, when it’s outputting to a terminal, ls lists files in columns, whose number varies depending on the length of the file names and the available space on screen.



    To find this kind of information, man ls works better than ls --help. (This is true for most commands.)






    share|improve this answer























    • man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
      – Andrew Henle
      Jul 20 at 11:57

















    up vote
    0
    down vote













    man ls contains (searched via /-1<Enter>)



     --format=WORD
    across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C


    ls -1 triggers the single column mode. ls by default displays its content in multiple columns, just like the column command line tool would.






    share|improve this answer

















    • 4




      The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
      – Kusalananda
      Jul 19 at 13:51











    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%2f457222%2fwhat-does-the-ls-1-command-do%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
    17
    down vote



    accepted










    Yes, the formatting of the output is the only difference between ls -1 and ls without any options.



    From the ls manual on my system:



     -1 (The numeric digit "one".) Force output to be one entry per line.
    This is the default when output is not to a terminal.


    This is also a POSIX option to the ls utility.



    The manual for ls on your system is bound to say something similar (see man ls).



    Related:



    • is piped ls the same as ls -1?





    share|improve this answer



























      up vote
      17
      down vote



      accepted










      Yes, the formatting of the output is the only difference between ls -1 and ls without any options.



      From the ls manual on my system:



       -1 (The numeric digit "one".) Force output to be one entry per line.
      This is the default when output is not to a terminal.


      This is also a POSIX option to the ls utility.



      The manual for ls on your system is bound to say something similar (see man ls).



      Related:



      • is piped ls the same as ls -1?





      share|improve this answer

























        up vote
        17
        down vote



        accepted







        up vote
        17
        down vote



        accepted






        Yes, the formatting of the output is the only difference between ls -1 and ls without any options.



        From the ls manual on my system:



         -1 (The numeric digit "one".) Force output to be one entry per line.
        This is the default when output is not to a terminal.


        This is also a POSIX option to the ls utility.



        The manual for ls on your system is bound to say something similar (see man ls).



        Related:



        • is piped ls the same as ls -1?





        share|improve this answer















        Yes, the formatting of the output is the only difference between ls -1 and ls without any options.



        From the ls manual on my system:



         -1 (The numeric digit "one".) Force output to be one entry per line.
        This is the default when output is not to a terminal.


        This is also a POSIX option to the ls utility.



        The manual for ls on your system is bound to say something similar (see man ls).



        Related:



        • is piped ls the same as ls -1?






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Jul 19 at 19:51









        Salman A

        1032




        1032











        answered Jul 19 at 13:39









        Kusalananda

        101k13199311




        101k13199311






















            up vote
            9
            down vote













            ls -1 lists one file per line. By default, when it’s outputting to a terminal, ls lists files in columns, whose number varies depending on the length of the file names and the available space on screen.



            To find this kind of information, man ls works better than ls --help. (This is true for most commands.)






            share|improve this answer























            • man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
              – Andrew Henle
              Jul 20 at 11:57














            up vote
            9
            down vote













            ls -1 lists one file per line. By default, when it’s outputting to a terminal, ls lists files in columns, whose number varies depending on the length of the file names and the available space on screen.



            To find this kind of information, man ls works better than ls --help. (This is true for most commands.)






            share|improve this answer























            • man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
              – Andrew Henle
              Jul 20 at 11:57












            up vote
            9
            down vote










            up vote
            9
            down vote









            ls -1 lists one file per line. By default, when it’s outputting to a terminal, ls lists files in columns, whose number varies depending on the length of the file names and the available space on screen.



            To find this kind of information, man ls works better than ls --help. (This is true for most commands.)






            share|improve this answer















            ls -1 lists one file per line. By default, when it’s outputting to a terminal, ls lists files in columns, whose number varies depending on the length of the file names and the available space on screen.



            To find this kind of information, man ls works better than ls --help. (This is true for most commands.)







            share|improve this answer















            share|improve this answer



            share|improve this answer








            edited Jul 19 at 13:50


























            answered Jul 19 at 13:39









            Stephen Kitt

            139k22296359




            139k22296359











            • man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
              – Andrew Henle
              Jul 20 at 11:57
















            • man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
              – Andrew Henle
              Jul 20 at 11:57















            man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
            – Andrew Henle
            Jul 20 at 11:57




            man ls works better than ls --help Especially so as --help is a non-portable non-POSIX extension.
            – Andrew Henle
            Jul 20 at 11:57










            up vote
            0
            down vote













            man ls contains (searched via /-1<Enter>)



             --format=WORD
            across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C


            ls -1 triggers the single column mode. ls by default displays its content in multiple columns, just like the column command line tool would.






            share|improve this answer

















            • 4




              The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
              – Kusalananda
              Jul 19 at 13:51















            up vote
            0
            down vote













            man ls contains (searched via /-1<Enter>)



             --format=WORD
            across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C


            ls -1 triggers the single column mode. ls by default displays its content in multiple columns, just like the column command line tool would.






            share|improve this answer

















            • 4




              The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
              – Kusalananda
              Jul 19 at 13:51













            up vote
            0
            down vote










            up vote
            0
            down vote









            man ls contains (searched via /-1<Enter>)



             --format=WORD
            across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C


            ls -1 triggers the single column mode. ls by default displays its content in multiple columns, just like the column command line tool would.






            share|improve this answer













            man ls contains (searched via /-1<Enter>)



             --format=WORD
            across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C


            ls -1 triggers the single column mode. ls by default displays its content in multiple columns, just like the column command line tool would.







            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Jul 19 at 13:43









            phy-shell

            365




            365







            • 4




              The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
              – Kusalananda
              Jul 19 at 13:51













            • 4




              The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
              – Kusalananda
              Jul 19 at 13:51








            4




            4




            The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
            – Kusalananda
            Jul 19 at 13:51





            The user is on a BSD system, judging from what ls --help produces. Their manual would unlikely contain --format.
            – Kusalananda
            Jul 19 at 13:51













             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457222%2fwhat-does-the-ls-1-command-do%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay