Find with Array in itAuto-expansion problem with array elements containing an '*' (asterisk)Find Command:...

In which ways do anagamis still experience ignorance?

Why does Hellboy file down his horns?

What's the point of this scene involving Flash Thompson at the airport?

Should you avoid redundant information after dialogue?

How does one stock fund's charge of 1% more in operating expenses than another fund lower expected returns by 10%?

How can I deal with a player trying to insert real-world mythology into my homebrew setting?

Is purchasing foreign currency before going abroad a losing proposition?

Why does the trade federation become so alarmed upon learning the ambassadors are Jedi Knights?

Interpreting the word "randomly"

latinate or other words of foreign origin as opposed to Germanic words

Can I intentionally omit previous work experience or pretend it doesn't exist when applying for jobs?

Why did the Japanese attack the Aleutians at the same time as Midway?

What does `[$'rn']` mean?

Supporting developers who insist on using their pet language

If the derivative of a function is square of it then it is constant

Cubic programming and beyond?

Are there any double stars that I can actually see orbit each other?

Does Google Maps take into account hills/inclines for route times?

Can anybody provide any information about this equation?

Missing Contours in ContourPlot

Is killing off one of my queer characters homophobic?

Players of unusual orchestral instruments

Measuring mystery distances

Why doesn't the Lars family (and thus Luke) speak Huttese as their first language?



Find with Array in it


Auto-expansion problem with array elements containing an '*' (asterisk)Find Command: File Path vs -name ArgumentRedirection Error in FunctionSet variables into script before or after SCPCGI with Shell Scriptfor each with array w/ multiple itemsread path name with spaces then use the variable into find commandIndex range of array doesn't allow you to iterate over a new line in bashFind latest file by numbered extensionCharacters randomly disappearring from the output of “find”






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















Why do this script work?



str=( -name "*.conf" -o -name "test test" )
find ./ ( "${str[@]}" )


And this script not work?



str[0]="-name"
str[1]=""*.conf""
str[2]="-o"
str[3]="-name"
str[4]=""test test""
find ./ ( "${str[@]}" )


It looks like error here: str[1]=""*.conf""



I'm interested in the second case.










share|improve this question























  • To see how they differ, turn debugging on in your shell (set -x)

    – steeldriver
    14 mins ago


















0















Why do this script work?



str=( -name "*.conf" -o -name "test test" )
find ./ ( "${str[@]}" )


And this script not work?



str[0]="-name"
str[1]=""*.conf""
str[2]="-o"
str[3]="-name"
str[4]=""test test""
find ./ ( "${str[@]}" )


It looks like error here: str[1]=""*.conf""



I'm interested in the second case.










share|improve this question























  • To see how they differ, turn debugging on in your shell (set -x)

    – steeldriver
    14 mins ago














0












0








0








Why do this script work?



str=( -name "*.conf" -o -name "test test" )
find ./ ( "${str[@]}" )


And this script not work?



str[0]="-name"
str[1]=""*.conf""
str[2]="-o"
str[3]="-name"
str[4]=""test test""
find ./ ( "${str[@]}" )


It looks like error here: str[1]=""*.conf""



I'm interested in the second case.










share|improve this question














Why do this script work?



str=( -name "*.conf" -o -name "test test" )
find ./ ( "${str[@]}" )


And this script not work?



str[0]="-name"
str[1]=""*.conf""
str[2]="-o"
str[3]="-name"
str[4]=""test test""
find ./ ( "${str[@]}" )


It looks like error here: str[1]=""*.conf""



I'm interested in the second case.







shell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 37 mins ago









UnixUserUnixUser

254 bronze badges




254 bronze badges













  • To see how they differ, turn debugging on in your shell (set -x)

    – steeldriver
    14 mins ago



















  • To see how they differ, turn debugging on in your shell (set -x)

    – steeldriver
    14 mins ago

















To see how they differ, turn debugging on in your shell (set -x)

– steeldriver
14 mins ago





To see how they differ, turn debugging on in your shell (set -x)

– steeldriver
14 mins ago










1 Answer
1






active

oldest

votes


















0














This:



str=( -name "*.conf" -o -name "test test" )


Is (usually) the same as this:



str=( "-name" "*.conf" "-o" "-name" "test test" )


Most of those quotes are omitted because they're not necessary - there are no wildcards for filename expansion, or whitespace characters from the default IFS that might cause field splitting for those elements.



So the equivalent could be:



declare -a str
str[0]="-name"
str[1]="*.conf"
str[2]="-o"
str[3]="-name"
str[4]="test test"


Or:



declare -a str
str[0]=-name
str[1]=*.conf # no filename expansion in variable assignment
str[2]=-o
str[3]=-name
str[4]="test test"





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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f530035%2ffind-with-array-in-it%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









    0














    This:



    str=( -name "*.conf" -o -name "test test" )


    Is (usually) the same as this:



    str=( "-name" "*.conf" "-o" "-name" "test test" )


    Most of those quotes are omitted because they're not necessary - there are no wildcards for filename expansion, or whitespace characters from the default IFS that might cause field splitting for those elements.



    So the equivalent could be:



    declare -a str
    str[0]="-name"
    str[1]="*.conf"
    str[2]="-o"
    str[3]="-name"
    str[4]="test test"


    Or:



    declare -a str
    str[0]=-name
    str[1]=*.conf # no filename expansion in variable assignment
    str[2]=-o
    str[3]=-name
    str[4]="test test"





    share|improve this answer




























      0














      This:



      str=( -name "*.conf" -o -name "test test" )


      Is (usually) the same as this:



      str=( "-name" "*.conf" "-o" "-name" "test test" )


      Most of those quotes are omitted because they're not necessary - there are no wildcards for filename expansion, or whitespace characters from the default IFS that might cause field splitting for those elements.



      So the equivalent could be:



      declare -a str
      str[0]="-name"
      str[1]="*.conf"
      str[2]="-o"
      str[3]="-name"
      str[4]="test test"


      Or:



      declare -a str
      str[0]=-name
      str[1]=*.conf # no filename expansion in variable assignment
      str[2]=-o
      str[3]=-name
      str[4]="test test"





      share|improve this answer


























        0












        0








        0







        This:



        str=( -name "*.conf" -o -name "test test" )


        Is (usually) the same as this:



        str=( "-name" "*.conf" "-o" "-name" "test test" )


        Most of those quotes are omitted because they're not necessary - there are no wildcards for filename expansion, or whitespace characters from the default IFS that might cause field splitting for those elements.



        So the equivalent could be:



        declare -a str
        str[0]="-name"
        str[1]="*.conf"
        str[2]="-o"
        str[3]="-name"
        str[4]="test test"


        Or:



        declare -a str
        str[0]=-name
        str[1]=*.conf # no filename expansion in variable assignment
        str[2]=-o
        str[3]=-name
        str[4]="test test"





        share|improve this answer













        This:



        str=( -name "*.conf" -o -name "test test" )


        Is (usually) the same as this:



        str=( "-name" "*.conf" "-o" "-name" "test test" )


        Most of those quotes are omitted because they're not necessary - there are no wildcards for filename expansion, or whitespace characters from the default IFS that might cause field splitting for those elements.



        So the equivalent could be:



        declare -a str
        str[0]="-name"
        str[1]="*.conf"
        str[2]="-o"
        str[3]="-name"
        str[4]="test test"


        Or:



        declare -a str
        str[0]=-name
        str[1]=*.conf # no filename expansion in variable assignment
        str[2]=-o
        str[3]=-name
        str[4]="test test"






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 20 mins ago









        murumuru

        41.6k5 gold badges101 silver badges175 bronze badges




        41.6k5 gold badges101 silver badges175 bronze badges






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f530035%2ffind-with-array-in-it%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







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...