Re: stupid bash question

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



On Wed, Aug 15, 2012 at 05:19:22PM -0600, Larry Martell wrote:
> On Wed, Aug 15, 2012 at 5:08 PM, Craig White <craig.white@xxxxxxxxxx> wrote:
> > Some really good suggestions but unfortunately no dice
> >
> > On Aug 15, 2012, at 3:22 PM, Larry Martell wrote:
> >
> >> Run the script with -x to see what's happening. $NAME is probably
> >> getting expanded. You might have to set noglob.
> > ----
> > set +o noglob (inside or outside script made no difference
> 
> This worked for me:
> 
> $ cat t.sh
> set -o noglob
> NAME="*.mov"
> find . -maxdepth 1 -name $NAME -print
> 
> $ touch t.mov t2.mov
> $ bash t.sh
> ./t.mov
> ./t2.mov


how about something (seemingly simple) like this:

find out how many there are:

	count=`ls * | grep -c .MOV$`

then diagnose the result:

	if [ $count -ge 1 ]
		then
		do your stuff here
	else
		echo oops. nothing to do!
	fi

of course, there are pitfalls... we're asuming that there are only FILES
that would match the pattern ".MOV", no directories.

-- 
---- Fred Smith -- fredex@xxxxxxxxxxxxxxxxxxxxxx -----------------------------
                    The Lord detests the way of the wicked 
                  but he loves those who pursue righteousness.
----------------------------- Proverbs 15:9 (niv) -----------------------------
_______________________________________________
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