0

I have a path only part of which actually exists. I want my script to complete the entire path (the script is for backup purposes).

for example :

/home/usr/guy/WDcloud/Linux/pi/backup/usr1
                           ^
                           the actual path up to here exists

I can't use mkdir /home/usr/guy/WDcloud/Linux/pi/backup/usr1 since only part of it exists.

I want a script to check the entire path exists, and if not, complete missing directories and then commence backup for each user.

1
  • 2
    Your title is confusing. Could you clarify at all? I think -p is what you want as suggested
    – Zanna
    May 12, 2017 at 8:57

1 Answer 1

3

If the question is only about mkdir, use mkdir -p /your/partly/existing/path. From the man page:

-p Create any missing intermediate pathname components

But what do you mean by "backup for each use"?

1
  • 1
    User not use if I'm not wrong (see revision history). I think you are on the right track indeed, but if the question is unclear, ask for details in a comment
    – Zanna
    May 12, 2017 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .