It is currently Fri, 15 Oct 2021 20:46:12 GMT



 
Author Message
 Quick question

Is there an easier way (shorter) way to test if a directory exsist and if it
doesn't create it. I am using.

dir=/home/me

if [ -d $dir ]
then
        echo "Directory exsist"
else
        echo "Creating directory."
        mkdir $dir
fi

I have read the man page and some manuals and they didn't show of a way.
The manuals mentioned that if the test is true it returns an exit status
of 0 and if it fails it will return a non-zero exit status. Can you test
the exit status, if so how.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~
~                         ~
~ uunet!iex!neptune!danny ~
~ Whats in a sig. anyway? ~
~ IEX CORPORATION-        ~
~ 1400 Preston rd. #350   ~
~ Plano, TX. 75093        ~
~ (214) 612-2600          ~
~                         ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~
~                         ~
~ uunet!iex!neptune!danny ~



 Mon, 28 Feb 1994 00:12:58 GMT   
 Quick question

Yes, try this:

dir=/home/me
[ -d $dir ] || mkdir $dir

Daniel Lewart
d-lew...@uiuc.edu



 Mon, 28 Feb 1994 05:12:52 GMT   
 Quick question

Yes, just use:

        mkdir $dir 2>/dev/null

                                                        Michi.
--
      -m------- Michael Henning                 +61 75 950255
    ---mmm----- Pyramid Technology              +61 75 522475 FAX
  -----mmmmm--- Research Park, Bond University  mi...@ptcburp.ptcbu.oz.au
-------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA   uunet!munnari!ptcburp.oz!michi



 Mon, 28 Feb 1994 07:41:31 GMT   
 Quick question
How bout this

mkdir $dir 2>/dev/null && echo "Creating Directory" || echo "Directory Exists"

                        Bruce
--
-How long must we fight? How long        Courtesy of Bruce Varney
 until we can live in peace.             a...@sage.cc.purdue.edu
-Until the madmen are dead my son,      
 Or until they realize that they cannot count on us to do nothing



 Tue, 01 Mar 1994 02:05:24 GMT   
 Quick question
Exit status for any command is easy to check for since it's stored
in a variable.

  For a Bourne shell its called $?
  For a csh its called $status

--
    _      _     Dale DePriest          Sunnyvale, California
   /`) _  //     ingr!dazixca!dale       voice: (408) 747-7884
 o/_/ (_(_X_(`   d...@daisy.com



 Tue, 01 Mar 1994 03:19:15 GMT   
 
   [ 5 post ] 

Similar Threads

1. I have a Quick Question, need quick answer.

2. Quick question regarding Solaris 9

3. steps for changing modules.conf .. quick question

4. Quick question regarding 'includes'

5. quick question about compatibility of desktop environments

6. Quick Question

7. Quick Question

8. Quick Question

9. Quick Question...

10. quick question


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software