Coreutils (or otherwise) `ls`: don't append symbol indicating type when piped

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











up vote
0
down vote

favorite












Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?



the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.







share|improve this question
























    up vote
    0
    down vote

    favorite












    Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?



    the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?



      the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.







      share|improve this question












      Is there a way to get GNU coreutils ls (or any other open-source ls) to omit the trailing symbol (* for executable, / for directory, etc.) only when output is piped?



      the GNU ls has a --color[=WHEN] option accepting auto to automatically show colors when output is not piped, and omit the control sequences for colors when output is piped. I am looking for identical behavior regarding trailing symbols indicating filetype.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 27 at 19:35









      Ivan G.

      334




      334




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.



          function ls 
          if [ -t 1 ]
          then
          command ls -F "$@"
          else
          command ls "$@"
          fi



          Adjust the other default options as you like.






          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%2f427007%2fcoreutils-or-otherwise-ls-dont-append-symbol-indicating-type-when-piped%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.



            function ls 
            if [ -t 1 ]
            then
            command ls -F "$@"
            else
            command ls "$@"
            fi



            Adjust the other default options as you like.






            share|improve this answer
























              up vote
              1
              down vote



              accepted










              Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.



              function ls 
              if [ -t 1 ]
              then
              command ls -F "$@"
              else
              command ls "$@"
              fi



              Adjust the other default options as you like.






              share|improve this answer






















                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.



                function ls 
                if [ -t 1 ]
                then
                command ls -F "$@"
                else
                command ls "$@"
                fi



                Adjust the other default options as you like.






                share|improve this answer












                Presumably you have an alias for ls that's unconditionally adding the -F (or --classify) option. I would work around that by creating a wrapper function that tests whether the stdout is a terminal or not; only add the -F option if the output is a terminal.



                function ls 
                if [ -t 1 ]
                then
                command ls -F "$@"
                else
                command ls "$@"
                fi



                Adjust the other default options as you like.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 27 at 20:11









                Jeff Schaller

                31.2k846105




                31.2k846105






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f427007%2fcoreutils-or-otherwise-ls-dont-append-symbol-indicating-type-when-piped%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)