Find command argument - Names script is not working when it is being used in a variable
iname = "- iname '* py' 'incho: echo in: $ iname
does not work:
find $ Iname -exec grep "text" {} \
works:
find -name '* py' -exec grep "text" {} \ The real world is in script (this is my perspective using the arrays Is more readable than is) inamecmd = - inamearg = * py find $ Inamecmd $ inamearg -exec grep "text" {} \;
etc. .
When you type it in full:
Find -Name '* py' -exec grep "text" {} \; bash
recognizes that you use the term code * to use one quote . Find
for Py
. It then removes the single quote; Find
do not see them.
When you use a variable:
iname = "- iname '* py'" Find $ Iname -exec grep "text" {} \; No
bash
extension $ iname
on literal string -in '* py'
Delete single citations, Find
as a code, receives literal string '* py'
, hence files starting with only one citation And files ending with py '
. The extension of / p> iname
will not be:
find "$ Iname" -exec grep "text" {} \;
This time, instead of find
string -name '* py'
will be received as a single argument, two different arguments Instead of -name
and '* py'
. bash
displays only one round of removal quotes; This parameter does not do this again on the outcome of the extension.
The correct way of passing many arguments in one variable in one variable is to use an array: Find
Iname = (- iname "* py") " $ {Iname [@]} "-exec grep" text "'{}' \;
Comments
Post a Comment