[CentOS] stupid bash question
Kahlil Hodgson
kahlil.hodgson at dealmax.com.au
Thu Aug 16 22:14:08 UTC 2012
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,
Kal
--
Kahlil (Kal) Hodgson GPG: C9A02289
Head of Technology (m) +61 (0) 4 2573 0382
DealMax Pty Ltd (w) +61 (0) 3 9008 5281
Suite 1415
401 Docklands Drive
Docklands VIC 3008 Australia
"All parts should go together without forcing. You must remember that
the parts you are reassembling were disassembled by you. Therefore,
if you can't get them together again, there must be a reason. By all
means, do not use a hammer." -- IBM maintenance manual, 1925
More information about the CentOS
mailing list