[CentOS] stupid bash question

Fri Aug 17 00:00:10 UTC 2012
Craig White <craig.white at ttiltd.com>

On Aug 16, 2012, at 3:14 PM, Kahlil Hodgson wrote:

> On 16/08/12 08:19, Craig White wrote:
>> the relevant snippet is...
>> 
>> NAME="*.mov" cd $IN if test -n "$(find . -maxdepth 1 -name $NAME
>> -print -quit)"
>> 
> The problem is the outermost double quotes in the "$(...)" expression
> and figuring out how to pass the appropriate quotes into the subshell 
> created by the $(). One trick is to let the outer shell do the 
> interpolation first.
> 
> The following script may be informative:
> 
> ==========================================
> #!/bin/bash
> 
> NAME="*.mov"
> echo $NAME
> echo "$NAME"
> 
> echo $(echo $NAME)
> echo $(echo "$NAME")
> echo $(echo \"$NAME\")
> echo $(echo '$NAME')
> 
> echo "$(echo $NAME)"
> echo "$(echo "$NAME")"
> echo "$(echo \"$NAME\")"
> echo "$(echo '$NAME')"
> 
> if test -n "$(find . -name "$NAME")"
> then
>     echo FOUND IT
> fi
> ==========================================
> 
> Hope this helps,
----
sort of but the other suggestion was more than sufficient for my purposes.

Interesting that I could have the variable in double quotes inside the double quoted braces and it still worked. I would have never actually tried it.

Thanks

Craig