|
Prev: apt-get in Suse?
Next: How do I make bash echo commands
From: Aaron Gray on 30 Jun 2008 14:07 I need to create a directory if one does not exist. if [ -d test]; then mkdir test; fi does the opposite, how do it ? I have tried :- if [! -d test]; then mkdir test; fi but that does not work. Aaron
From: Lew Pitcher on 30 Jun 2008 14:23 In alt.os.linux, Aaron Gray wrote: > I need to create a directory if one does not exist. > > if [ -d test]; then mkdir test; fi > > does the opposite, how do it ? > > I have tried :- > > if [! -d test]; then mkdir test; fi > > but that does not work. It would, with proper formatting Try if [ ! -d test ] ; then mkdir test ; fi or [ ! -d test ] && mkdir test or [ -d test ] || mkdir test -- Lew Pitcher Master Codewright & JOAT-in-training | Registered Linux User #112576 http://pitcher.digitalfreehold.ca/ | GPG public key available by request ---------- Slackware - Because I know what I'm doing. ------
From: Aaron Gray on 30 Jun 2008 14:42 "Lew Pitcher" <lpitcher(a)teksavvy.com> wrote in message news:70069$486922c5$cef8b59e$24609(a)TEKSAVVY.COM-Free... > In alt.os.linux, Aaron Gray wrote: > >> I need to create a directory if one does not exist. >> >> if [ -d test]; then mkdir test; fi >> >> does the opposite, how do it ? >> >> I have tried :- >> >> if [! -d test]; then mkdir test; fi >> >> but that does not work. > > It would, with proper formatting > > Try > if [ ! -d test ] ; then mkdir test ; fi > or > [ ! -d test ] && mkdir test > or > [ -d test ] || mkdir test Great, thanks Lew. Aaron
From: Ben Collver on 30 Jun 2008 15:57 I have seen many a Makefile that just uses the -p flag. For example: mkdir -p test This will succeed even if the directory already exists. Cheers, Ben
From: Aaron Gray on 30 Jun 2008 16:02 "Ben Collver" <BenCollver(a)gmail.com> wrote in message news:f1f7ff6d-0833-4275-996d-54be4fa61e29(a)r37g2000prm.googlegroups.com... >I have seen many a Makefile that just uses the -p flag. For example: > > mkdir -p test > > This will succeed even if the directory already exists. Right, thanks, Aaron
|
Pages: 1 Prev: apt-get in Suse? Next: How do I make bash echo commands |