How to exclude multiple file extensions in tree?

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











up vote
2
down vote

favorite












When using the tree command, I'd like to exclude listing *.png and *.svg from the output. The problem is that every bracket expansion I try doesn't work. Is it because of how tree processes commandline arguments?



tree -I *.svg,png
tree -I '*.svg,png'
tree -I '*.svg,*.png'
tree -I '*.svg,*.png'
tree -I '*.p,s(v,n}g'
tree -I '*.png'


Specs:



  • GNU bash, version 4.4.23

  • tree v1.7.0






share|improve this question






















  • @Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
    – Hagbard Celine
    Aug 31 at 15:40















up vote
2
down vote

favorite












When using the tree command, I'd like to exclude listing *.png and *.svg from the output. The problem is that every bracket expansion I try doesn't work. Is it because of how tree processes commandline arguments?



tree -I *.svg,png
tree -I '*.svg,png'
tree -I '*.svg,*.png'
tree -I '*.svg,*.png'
tree -I '*.p,s(v,n}g'
tree -I '*.png'


Specs:



  • GNU bash, version 4.4.23

  • tree v1.7.0






share|improve this question






















  • @Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
    – Hagbard Celine
    Aug 31 at 15:40













up vote
2
down vote

favorite









up vote
2
down vote

favorite











When using the tree command, I'd like to exclude listing *.png and *.svg from the output. The problem is that every bracket expansion I try doesn't work. Is it because of how tree processes commandline arguments?



tree -I *.svg,png
tree -I '*.svg,png'
tree -I '*.svg,*.png'
tree -I '*.svg,*.png'
tree -I '*.p,s(v,n}g'
tree -I '*.png'


Specs:



  • GNU bash, version 4.4.23

  • tree v1.7.0






share|improve this question














When using the tree command, I'd like to exclude listing *.png and *.svg from the output. The problem is that every bracket expansion I try doesn't work. Is it because of how tree processes commandline arguments?



tree -I *.svg,png
tree -I '*.svg,png'
tree -I '*.svg,*.png'
tree -I '*.svg,*.png'
tree -I '*.p,s(v,n}g'
tree -I '*.png'


Specs:



  • GNU bash, version 4.4.23

  • tree v1.7.0








share|improve this question













share|improve this question




share|improve this question








edited Aug 31 at 15:31









Attie

8,70231935




8,70231935










asked Aug 31 at 15:23









Hagbard Celine

132




132











  • @Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
    – Hagbard Celine
    Aug 31 at 15:40

















  • @Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
    – Hagbard Celine
    Aug 31 at 15:40
















@Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
– Hagbard Celine
Aug 31 at 15:40





@Attie solved this for me in superuser.com/a/1354169/939457 The answer is tree -I '*.svg|*.png' Thank you!
– Hagbard Celine
Aug 31 at 15:40











1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










-I is the inverse of -P... the manual gives more information on what is acceptable for the latter:



https://linux.die.net/man/1/tree




-P pattern


List only those files that match the wild-card pattern.



Note: you must use the -a option to also consider those files beginning with a dot . for matching.



Valid wildcard operators are * (any zero or more characters), ? (any single character), [...] (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and [^...] (any single character not listed in brackets) and | separates alternate patterns.




There's no mention of the shell's brace expansion syntax of a,b... This expansion is handled by tree, not bash.



And unfortunately you can't specify -I multiple times...



Instead you need to list the full patterns with a pipe (|) to separate them:



tree -I '*.svg|*.png'


Note the use of single quotes to prevent the shell from expanding the asterisk (*) or variables (introduced by a dollar - $).




Note also that it's not even possible to coerce the shell's brace expansion, as shown below:



$ tree -I '*.'svg,png
+ tree -I '*.svg' '*.png'
*.png [error opening dir]





share|improve this answer






















    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
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1354165%2fhow-to-exclude-multiple-file-extensions-in-tree%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
    4
    down vote



    accepted










    -I is the inverse of -P... the manual gives more information on what is acceptable for the latter:



    https://linux.die.net/man/1/tree




    -P pattern


    List only those files that match the wild-card pattern.



    Note: you must use the -a option to also consider those files beginning with a dot . for matching.



    Valid wildcard operators are * (any zero or more characters), ? (any single character), [...] (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and [^...] (any single character not listed in brackets) and | separates alternate patterns.




    There's no mention of the shell's brace expansion syntax of a,b... This expansion is handled by tree, not bash.



    And unfortunately you can't specify -I multiple times...



    Instead you need to list the full patterns with a pipe (|) to separate them:



    tree -I '*.svg|*.png'


    Note the use of single quotes to prevent the shell from expanding the asterisk (*) or variables (introduced by a dollar - $).




    Note also that it's not even possible to coerce the shell's brace expansion, as shown below:



    $ tree -I '*.'svg,png
    + tree -I '*.svg' '*.png'
    *.png [error opening dir]





    share|improve this answer


























      up vote
      4
      down vote



      accepted










      -I is the inverse of -P... the manual gives more information on what is acceptable for the latter:



      https://linux.die.net/man/1/tree




      -P pattern


      List only those files that match the wild-card pattern.



      Note: you must use the -a option to also consider those files beginning with a dot . for matching.



      Valid wildcard operators are * (any zero or more characters), ? (any single character), [...] (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and [^...] (any single character not listed in brackets) and | separates alternate patterns.




      There's no mention of the shell's brace expansion syntax of a,b... This expansion is handled by tree, not bash.



      And unfortunately you can't specify -I multiple times...



      Instead you need to list the full patterns with a pipe (|) to separate them:



      tree -I '*.svg|*.png'


      Note the use of single quotes to prevent the shell from expanding the asterisk (*) or variables (introduced by a dollar - $).




      Note also that it's not even possible to coerce the shell's brace expansion, as shown below:



      $ tree -I '*.'svg,png
      + tree -I '*.svg' '*.png'
      *.png [error opening dir]





      share|improve this answer
























        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        -I is the inverse of -P... the manual gives more information on what is acceptable for the latter:



        https://linux.die.net/man/1/tree




        -P pattern


        List only those files that match the wild-card pattern.



        Note: you must use the -a option to also consider those files beginning with a dot . for matching.



        Valid wildcard operators are * (any zero or more characters), ? (any single character), [...] (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and [^...] (any single character not listed in brackets) and | separates alternate patterns.




        There's no mention of the shell's brace expansion syntax of a,b... This expansion is handled by tree, not bash.



        And unfortunately you can't specify -I multiple times...



        Instead you need to list the full patterns with a pipe (|) to separate them:



        tree -I '*.svg|*.png'


        Note the use of single quotes to prevent the shell from expanding the asterisk (*) or variables (introduced by a dollar - $).




        Note also that it's not even possible to coerce the shell's brace expansion, as shown below:



        $ tree -I '*.'svg,png
        + tree -I '*.svg' '*.png'
        *.png [error opening dir]





        share|improve this answer














        -I is the inverse of -P... the manual gives more information on what is acceptable for the latter:



        https://linux.die.net/man/1/tree




        -P pattern


        List only those files that match the wild-card pattern.



        Note: you must use the -a option to also consider those files beginning with a dot . for matching.



        Valid wildcard operators are * (any zero or more characters), ? (any single character), [...] (any single character listed between brackets (optional - (dash) for character range may be used: ex: [A-Z]), and [^...] (any single character not listed in brackets) and | separates alternate patterns.




        There's no mention of the shell's brace expansion syntax of a,b... This expansion is handled by tree, not bash.



        And unfortunately you can't specify -I multiple times...



        Instead you need to list the full patterns with a pipe (|) to separate them:



        tree -I '*.svg|*.png'


        Note the use of single quotes to prevent the shell from expanding the asterisk (*) or variables (introduced by a dollar - $).




        Note also that it's not even possible to coerce the shell's brace expansion, as shown below:



        $ tree -I '*.'svg,png
        + tree -I '*.svg' '*.png'
        *.png [error opening dir]






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 31 at 15:36

























        answered Aug 31 at 15:30









        Attie

        8,70231935




        8,70231935



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1354165%2fhow-to-exclude-multiple-file-extensions-in-tree%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