For example, I want to run find
but the parameter is stored in a varibile.
a='-name "build.sh"'
find . $a
It shows error: find: -name "build.sh": unknown primary or operator
I hope it runs like find . -name "build.sh"
, how to put the var as parameter`?
Thank you.
CodePudding user response:
Throw your code into a file and then use shellcheck on it, and it will lead you to this page:
https://github.com/koalaman/shellcheck/wiki/SC2089
Quotes/backslashes will be treated literally. Use an array.
Do it this way, instead:
a=(-name "build.sh")
find . "${a[@]}"