setup directory tree


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting setup directory tree
# 1  
Old 11-13-2007
setup directory tree

All,
I am new to Unix scripting ans was looking for some guidance.

I basically have to:
1. Check if a directory exists - if not create it
2. Check the permissions of the dir - if Wrong change
loop this.

Sort of creating a directory tree.

Thanks.

Last edited by wicked24; 11-13-2007 at 08:19 AM.. Reason: Hit enter key by mistake
# 2  
Old 11-13-2007
To make a directory tree, even if some don't exists, use :

Code:
mkdir -p toto/titi/tata/tutu

Use umask command to set default rights on creation.
Use chmod command to set rights after creation.

Good luck.
# 3  
Old 11-15-2007
Hammer & Screwdriver Maybe this will help

Ok - Here is what I need:
Below is the directory structure that I want to create and set permissions on.
Directory Permissions
/apps/ki01/logs/app_yyxzzz drwxr-xr-x
/apps/ki01/bin/app_yyxzzz drwxr-xr--
/apps/ki01/scripts/app_yyxzzz drwxr-xr--
/apps/ki01/src/app_yyxzzz drwxr-xr--
/apps/ki01/ssl/app_yyxzzz/ drwxr-x---
/apps/ki01/htdocs/IHS_yyxzzz/ drwxr-xr--
/apps/ki01/ssl/IHS_yyxzzz/ drwxr-x---
/export/home/trace/app_yyxzzz/ drwxr-xr-x

1st - I need to check if the directory already exists and also if it matches the permissions.
2nd - if not then create the directory and set correct permissions.
This is for all directories.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To do directory tree search

Hello Everyone, I need to find the file / directory with the maximum timestamp in a directory tree having many files / directories. Could you please help. Thanks, H squared (3 Replies)
Discussion started by: H squared
3 Replies

2. Shell Programming and Scripting

Specific directory parsing in a directory tree

Hi friends, Hello again :) i got stuck in problem. Is there any way to get a special directory from directory tree? Here is my problm.." Suppose i have one fix directory structure "/abc/xyz/pqr/"(this will be fix).Under this directory structure i have some other directory and... (6 Replies)
Discussion started by: harpal singh
6 Replies

3. UNIX for Dummies Questions & Answers

directory tree with directory size

find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/' Can someone explain how this works..?? How can i add directory size to be listed in the above command's output..?? (1 Reply)
Discussion started by: vikram3.r
1 Replies

4. UNIX for Dummies Questions & Answers

Fllatten directory tree

Hi there, I have a filestore that is just two levels: dir/ file1 file2 file3 ... subdir1/ file4 file5 file6 subdir2/ file7 file8 file9 ... I am looking for acommand or scrip that will flatteb this tree and copy all the... (6 Replies)
Discussion started by: loquela
6 Replies

5. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies

6. Shell Programming and Scripting

directory tree

Hi all, The following is a script for displaying directory tree. D=${1:-`pwd`} (cd $D; pwd) find $D -type d -print | sort | sed -e "s,^$D,,"\ -e "/^$/d"\ -e "s,*/\(*\)$,\:-----\1,"\ -e "s,*/,: ,g" | more exit 0 I am trying to understand the above script.But... (3 Replies)
Discussion started by: ravi raj kumar
3 Replies

7. Shell Programming and Scripting

Searching directory tree

I'm currently trying to write a script that will do the following: search a given directory tree for a file with MMDDYYYY in the name. delete those files only. I can't figure out how to make the script delete the files with the MMDDYYYY in the filename after finding them. Should I export... (7 Replies)
Discussion started by: blane
7 Replies

8. Programming

directory as tree

hi i have modified a program to display directory entries recursively in a tree like form i need an output with the following guidelines: the prog displays the contents of the directory the directory contents are sorted before printing so that directories come before regular files if an entry... (2 Replies)
Discussion started by: anything2
2 Replies

9. Filesystems, Disks and Memory

Space Used by Directory Tree

Can someone tell me how I can determine how much space (blocks) have been used by a given directory tree? I periodically need to know how much space is consumed by a directory and all of its files and subdirectories and their files in either KB or blocks. I have tried df and du but these do not... (1 Reply)
Discussion started by: johnk99
1 Replies

10. Programming

Directory tree search???

Hi all, I've got a problem, what function do i use to list the contents of all the directory tree (simular to "find")? Any other suggestions? Thank you all (3 Replies)
Discussion started by: solvman
3 Replies
Login or Register to Ask a Question