Re: stupid bash question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I gess you could also avoid the expension with:
if test -n "$(find . -maxdepth 1 -name \"$NAME\" -print -quit)"

2012/8/15 Steve Thompson <smt@xxxxxxxxxxxx>:
> On Wed, 15 Aug 2012, Craig White wrote:
>
>> the relevant snippet is...
>>
>> NAME="*.mov"
>> cd $IN
>> if test -n "$(find . -maxdepth 1 -name $NAME -print -quit)"
>>
>> and if there is one file in this directory - ie test.mov, this works fine
>>
>> but if there are two (or more) files in this directory - test.mov, test2.mov
>>
>> then I get an error...
>> find: paths must precede expression
>
> The substitution of $NAME is expanding the wild card, giving you a single
> -name with two arguments. You probably want something like:
>
>         NAME="\*.mov"
>
> Steve
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux