| |||
| Quick bash question 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 |
| |||
| Re: Quick bash question 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. ------ |
| |||
| Re: Quick bash question "Lew Pitcher" <lpitcher@teksavvy.com> wrote in message news:70069$486922c5$cef8b59e$24609@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 |
| |||
| Re: Quick bash question "Ben Collver" <BenCollver******.com> wrote in message news:f1f7ff6d-0833-4275-996d-54be4fa61e29@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 |
![]() |
| Bookmarks |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| bash question | Eric | Linux | 5 | 02-08-2008 01:30 AM |
| Quick question. | Red2Blue | Windows Vista | 1 | 10-22-2007 06:20 PM |
| cron.daily bash scripting question | Beowulf | Linux | 2 | 01-15-2007 12:02 PM |
| Re: Quick question | Chris H. | Microsoft OneNote | 0 | 01-07-2007 12:15 AM |
| A quick question for someone | niknik1971 | Windows Vista | 1 | 01-01-2007 09:35 PM |