[CentOS] stupid bash question

fred smith fredex at fcshome.stoneham.ma.us
Thu Aug 16 00:11:06 UTC 2012


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 at ttiltd.com> 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 at fcshome.stoneham.ma.us -----------------------------
                    The Lord detests the way of the wicked 
                  but he loves those who pursue righteousness.
----------------------------- Proverbs 15:9 (niv) -----------------------------



More information about the CentOS mailing list