0

I have this code:

        if (( i == 0 )); then
            findCommand="find . -name \"${id}*0${month}*\" | sort -r | head -1"
        else
            findCommand="find . -name \"${id}*0${month}*\""
        fi

        while read fileName; do
            data[i]=$(sed -n -f sed_script "${fileName}")
            trim=${fileName#./* }
            period[i]=${trim%.json}
        done < <(${findCommand})

My problem with it is that the process substitution is returning nothing, I suposse It has to do with the wildcard expansion but I have no idea how to properly escape the findCommand string so that the wildcard expansion is properly done.

  • 2
    Does this answer your question? [How can we run a command stored in a variable?](https://unix.stackexchange.com/questions/444946/how-can-we-run-a-command-stored-in-a-variable) – muru Sep 02 '23 at 23:49
  • You have tagged your question with `ksh`. Is the shell you are using the Korn shell? – Kusalananda Sep 03 '23 at 05:12

0 Answers0