in bash how do I loop through directories starting with “abc” and the directory “special-dir”











up vote
-1
down vote

favorite












I have this code:



for dir in abc*/ ; do
echo $dir
done


This works, but I have one special directory (lets say its called "special-dir"). How can I add that to my loop, I am thinking somthing like:



for dir in abc*/ + "special-dir" ; do
echo $dir
done


Obvously that does not work!, but I can't quite think how to do this.










share|improve this question


















  • 1




    Drop the + and you are good to go.
    – Socowi
    Nov 7 at 12:28












  • @Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
    – code_fodder
    Nov 7 at 12:30










  • Thanks. There's already an answer here, so I pass.
    – Socowi
    Nov 7 at 12:31










  • @Socowi ok, yours was first (just), but thanks anyway : )
    – code_fodder
    Nov 7 at 12:32










  • Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
    – jww
    Nov 7 at 15:54















up vote
-1
down vote

favorite












I have this code:



for dir in abc*/ ; do
echo $dir
done


This works, but I have one special directory (lets say its called "special-dir"). How can I add that to my loop, I am thinking somthing like:



for dir in abc*/ + "special-dir" ; do
echo $dir
done


Obvously that does not work!, but I can't quite think how to do this.










share|improve this question


















  • 1




    Drop the + and you are good to go.
    – Socowi
    Nov 7 at 12:28












  • @Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
    – code_fodder
    Nov 7 at 12:30










  • Thanks. There's already an answer here, so I pass.
    – Socowi
    Nov 7 at 12:31










  • @Socowi ok, yours was first (just), but thanks anyway : )
    – code_fodder
    Nov 7 at 12:32










  • Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
    – jww
    Nov 7 at 15:54













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have this code:



for dir in abc*/ ; do
echo $dir
done


This works, but I have one special directory (lets say its called "special-dir"). How can I add that to my loop, I am thinking somthing like:



for dir in abc*/ + "special-dir" ; do
echo $dir
done


Obvously that does not work!, but I can't quite think how to do this.










share|improve this question













I have this code:



for dir in abc*/ ; do
echo $dir
done


This works, but I have one special directory (lets say its called "special-dir"). How can I add that to my loop, I am thinking somthing like:



for dir in abc*/ + "special-dir" ; do
echo $dir
done


Obvously that does not work!, but I can't quite think how to do this.







linux bash loops






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 12:25









code_fodder

4,87563772




4,87563772








  • 1




    Drop the + and you are good to go.
    – Socowi
    Nov 7 at 12:28












  • @Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
    – code_fodder
    Nov 7 at 12:30










  • Thanks. There's already an answer here, so I pass.
    – Socowi
    Nov 7 at 12:31










  • @Socowi ok, yours was first (just), but thanks anyway : )
    – code_fodder
    Nov 7 at 12:32










  • Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
    – jww
    Nov 7 at 15:54














  • 1




    Drop the + and you are good to go.
    – Socowi
    Nov 7 at 12:28












  • @Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
    – code_fodder
    Nov 7 at 12:30










  • Thanks. There's already an answer here, so I pass.
    – Socowi
    Nov 7 at 12:31










  • @Socowi ok, yours was first (just), but thanks anyway : )
    – code_fodder
    Nov 7 at 12:32










  • Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
    – jww
    Nov 7 at 15:54








1




1




Drop the + and you are good to go.
– Socowi
Nov 7 at 12:28






Drop the + and you are good to go.
– Socowi
Nov 7 at 12:28














@Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
– code_fodder
Nov 7 at 12:30




@Socowi ahhh... sweet :) .. if you want to add it as an answer I'll mark it up
– code_fodder
Nov 7 at 12:30












Thanks. There's already an answer here, so I pass.
– Socowi
Nov 7 at 12:31




Thanks. There's already an answer here, so I pass.
– Socowi
Nov 7 at 12:31












@Socowi ok, yours was first (just), but thanks anyway : )
– code_fodder
Nov 7 at 12:32




@Socowi ok, yours was first (just), but thanks anyway : )
– code_fodder
Nov 7 at 12:32












Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
– jww
Nov 7 at 15:54




Please, allow us to Google that for you: bash loop over multiple directories site:stackoverflow.com
– jww
Nov 7 at 15:54












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The path expansion just expands the glob to list of the actual directories. Word list is space separated, so just use space to separate the next element of the list:



for dir in abc*/ special-dir ; do
echo "$dir"
done





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189439%2fin-bash-how-do-i-loop-through-directories-starting-with-abc-and-the-directory%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    The path expansion just expands the glob to list of the actual directories. Word list is space separated, so just use space to separate the next element of the list:



    for dir in abc*/ special-dir ; do
    echo "$dir"
    done





    share|improve this answer

























      up vote
      1
      down vote



      accepted










      The path expansion just expands the glob to list of the actual directories. Word list is space separated, so just use space to separate the next element of the list:



      for dir in abc*/ special-dir ; do
      echo "$dir"
      done





      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        The path expansion just expands the glob to list of the actual directories. Word list is space separated, so just use space to separate the next element of the list:



        for dir in abc*/ special-dir ; do
        echo "$dir"
        done





        share|improve this answer












        The path expansion just expands the glob to list of the actual directories. Word list is space separated, so just use space to separate the next element of the list:



        for dir in abc*/ special-dir ; do
        echo "$dir"
        done






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 12:29









        choroba

        152k14138199




        152k14138199






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189439%2fin-bash-how-do-i-loop-through-directories-starting-with-abc-and-the-directory%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings