Re: Q re: if test of command in bash script

2008-10-28 Thread Boyd Stephen Smith Jr.
On Tuesday 28 October 2008 02:28:16 pm Ken Irving wrote: >On Tue, Oct 28, 2008 at 01:57:40PM -0500, Kent West wrote: >> Ken Irving wrote: >> > echo -e "YES, '$targetDir exists!\n\n" >> >> Ah, the "-e" enables things like newlines and the bell character. > >I use it a lot (but I think ju

Re: Q re: if test of command in bash script

2008-10-28 Thread Ken Irving
On Tue, Oct 28, 2008 at 01:57:40PM -0500, Kent West wrote: > Ken Irving wrote: > ... > > I'd tend to format the above code a little differently, but here's > > the same thing with the `if' using the mkdir command directly: > > > > if [ -d $targetDir ]; then > > echo -e "YES, '$targe

Re: Q re: if test of command in bash script

2008-10-28 Thread Kent West
Ken Irving wrote: > The [ ... ] construct isn't needed for a command like mkdir, just > for conditional tests of variables and strings (see CONDITIONAL > EXPRESSIONS in bash(1)). > Ah, beginning to coalesce in my brain now. > I'd tend to format the above code a little differently, but here's >

Re: Q re: if test of command in bash script

2008-10-28 Thread Kurian Thayil
Kent West wrote: > Chris Jones wrote: > >> if mkdir; then >> echo 'created OK' >> else >> echo 'not created OK' >> exit 1 >> >> >> ... the [] is redundant, IOW: >> >> if test mkdir# ??? >> >> also your sample has the then/else actions inverted. >> >> > > T

Re: Q re: if test of command in bash script

2008-10-28 Thread Ken Irving
On Tue, Oct 28, 2008 at 11:42:09AM -0500, Kent West wrote: > === > > echo "Does target directory '$targetDir' exist?" > if [ -d $targetDir ] > then > echo "YES, '$targetDir exists!" > echo > else > echo "No, '$targetDir' does not exis

Re: Q re: if test of command in bash script

2008-10-28 Thread Kent West
Chris Jones wrote: > if mkdir; then > echo 'created OK' > else > echo 'not created OK' > exit 1 > > > ... the [] is redundant, IOW: > > if test mkdir # ??? > > also your sample has the then/else actions inverted. > Thank you. I thought I had tried it without t

Re: Q re: if test of command in bash script

2008-10-28 Thread Steve Kemp
On Tue Oct 28, 2008 at 11:42:09 -0500, Kent West wrote: > if [ mkdir -p $targetDir ] # If the mkdir fails Use: if ( mkdir -p $targetDir ) Steve -- http://www.steve.org.uk/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Co

Q re: if test of command in bash script

2008-10-28 Thread Kent West
Hey all! After a couple of hours of searching, I've decided that both my scripting-foo and my google-foo are weak this morning, so I turn to you folks for a quick answer. In a bash script, I'm trying to create a directory and test if it is successful. The man page doesn't indicate what mkdir ret