![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to check if a direcorty exists? | SunnyK | Shell Programming and Scripting | 2 | 11-08-2007 10:47 AM |
| how to check the actual path instead of link path | reldb | UNIX for Advanced & Expert Users | 4 | 10-04-2006 09:55 AM |
| check if directory exists | jerardfjay | Shell Programming and Scripting | 2 | 06-13-2005 02:26 PM |
| check if exists a .ZIP file and unzip it using ftp | DebianJ | Shell Programming and Scripting | 1 | 05-05-2005 04:46 PM |
| perl ftp check file exists | methos | Shell Programming and Scripting | 2 | 06-18-2003 08:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to check if all directories of file's path exists?
I wonder if the script below is possible to write somehow more efficiently. It seems to me the problem is very common..
CreateFolders() # parameter: name of file with relative path with regard to directory $project_root { echo $1 | awk '{ n=split($1, array, "/"); for (i=1;i<n;i++) { print array[i] } } ' >"$project_root/createDirectory.tmp" if [ -s "$project_root/createDirectory.tmp" ]; then folder=$project_root while read subdir; do if [ ! -d "$folder/$subdir" ];then mkdir "$folder/$subdir" fi cd "$folder/$subdir" folder="$folder/$subdir" done<"$project_root/createDirectory.tmp" fi rm "$project_root/createDirectory.tmp"; } Thank you for help |
|
||||
|
I'm not sure I understand what you exactly are trying to do.
You can use mkdir -p <directory tree> to create the whole tree in one go e.g.: folder=${project_root}/local/pub/etc mkdir -p $folder |
|
||||
|
thanks you! it's pretty faster way
![]() |
| Sponsored Links | ||
|
|