Re: [CentOS] stupid bash question

2012-08-16 Thread Craig White
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 figu

Re: [CentOS] stupid bash question

2012-08-16 Thread Kahlil Hodgson
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 cre

Re: [CentOS] stupid bash question

2012-08-16 Thread Craig White
On Aug 15, 2012, at 5:11 PM, fred smith wrote: > 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 >

Re: [CentOS] stupid bash question

2012-08-15 Thread Mark LaPierre
On 08/15/2012 06:19 PM, 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 -

Re: [CentOS] stupid bash question

2012-08-15 Thread fred smith
On Wed, Aug 15, 2012 at 05:19:22PM -0600, Larry Martell wrote: > On Wed, Aug 15, 2012 at 5:08 PM, Craig White 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 i

Re: [CentOS] stupid bash question

2012-08-15 Thread Larry Martell
On Wed, Aug 15, 2012 at 5:08 PM, Craig White 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

Re: [CentOS] stupid bash question

2012-08-15 Thread Craig White
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 On Au

Re: [CentOS] stupid bash question

2012-08-15 Thread Patrick Welch
Put escaped double quotes around name, like \"$NAME\" in the test expression. -- Pat Welch Sent from my Android phone with K-9 Mail. 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

Re: [CentOS] stupid bash question

2012-08-15 Thread Jérémie Dubois-Lacoste
I gess you could also avoid the expension with: if test -n "$(find . -maxdepth 1 -name \"$NAME\" -print -quit)" 2012/8/15 Steve Thompson : > 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 -

Re: [CentOS] stupid bash question

2012-08-15 Thread Steve Thompson
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 - te

Re: [CentOS] stupid bash question

2012-08-15 Thread Larry Martell
On Wed, Aug 15, 2012 at 4:19 PM, 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 di

[CentOS] stupid bash question

2012-08-15 Thread Craig White
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 mu