Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I’m running a expect script to save config files. I want the script to check if a directory exist and if not create it. Anyone who knows how to ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    2

    Expect Script

    Hi

    I’m running a expect script to save config files.
    I want the script to check if a directory exist and if not create it.

    Anyone who knows how to do that?

  2. #2
    Just Joined! bclark4444's Avatar
    Join Date
    Dec 2003
    Posts
    55
    i usually do the following:
    mkdir -p /home/mydir/whatever

    The breakdown of this is that i really dont care if it already exists, i just want to make sure it exists when my command is done. The '-p' will make all necessary directories (including parents) to insure that it exists and will remain silent if they are already existing. So for example, if i dont have either 'mydir' or 'whatever' then it will create both. If i have 'mydir', but not 'whatever' then it will create only the one. If i have both, then it will remain silent and return.

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    2
    Thank you very much, it works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...