Testing for a folder
I want to write a BASH script which can detect if a folder exists on the disk.
What command do I use? Thanks for your help. Ian |
if [ -d /where/ever ]
... fi |
Thanks, That gets me going.
Actually, I need to mkdir if the folder does not exist (which I realize is not what I asked for) and I find that I have to say if [ -d $folder ]; then nothing=1 else mkdir $folder fi I know that you will be able to tell me a more elegant way to do this than having a dummy assignment statement. Ian :newbie: |
[ -d /where/ever ] || mkdir /where/ever
|
A slightly concise solution...
Code:
if [ ! -d /what/ever] ; then |
mine's conciserer. i could say [ ! -d /where/ever ] && mkdir /where/ever but that uses two more characters!
|
Great!
Elegant! Works! |
All times are GMT -5. The time now is 05:03 PM. |