Creation of multiple directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creation of multiple directories
# 1  
Old 05-11-2010
Creation of multiple directories

I have a folder structure like the below

/test/test1/test2/app
/test/test3/app
/test/test4/test5/app
..


I need to create a new folder under "app" in all the above listed directory structure at one shot by the name "subapp" .

How can we acheive this using a script .

New to unix scripting hence request the direction .

Thanks all .
# 2  
Old 05-11-2010
Code:
 find /test -type d -name "app" -exec mkdir {}/subapp \;

# 3  
Old 05-11-2010
Hi , Thanks for the quick reply .

But getting a error when i try to test it out ..

Code:
$ pwd
/tmp/rajesh
$ cd fol1
$ ls -ltr
total 0
drwxr-xr-x    2 wmuser   wmftp           256 May 11 17:28 sub
$ cd ../fol2
$ ls -ltr
total 0
drwxr-xr-x    2 wmuser   wmftp           256 May 11 17:28 sub
$ cd ../fol3
$ ls -ltr
total 0
drwxr-xr-x    2 wmuser   wmftp           256 May 11 17:29 sub
$ find /tmp/rajesh -type d -name "sub" -exec mkdir {}/subapp \;
mkdir: 0653-357 Cannot access directory {}.
{}: A file or directory in the path name does not exist.
mkdir: 0653-357 Cannot access directory {}.
{}: A file or directory in the path name does not exist.
mkdir: 0653-357 Cannot access directory {}.
{}: A file or directory in the path name does not exist.
$


Last edited by pludi; 05-11-2010 at 06:43 AM.. Reason: code tags, please...
# 4  
Old 05-11-2010
Hi.

Try with xargs:

Code:
find . -type d -name sub | xargs -I{} mkdir {}/subapp

This User Gave Thanks to Scott For This Post:
# 5  
Old 05-11-2010
THANKS scottn , It works .

Thanks all the quick replies .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Creation of directories

i am having trouble creating a directory with last months date as the folder name. what i am using is echo `date +%b%y` which gives Mar14 as the result but i want to get Feb14 as the result.:wall: (6 Replies)
Discussion started by: simkazw
6 Replies

2. UNIX for Dummies Questions & Answers

List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, having given pattern in the directories name, sorted by creation date. Example: Directories with name "pkg32*" or "pkg33*" 2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies

3. Shell Programming and Scripting

Automating creation of directories

I have a top-level directory called work and I would like to create subdirectories work1 work2... under this directory. Also I would like to create subdirectory under work1 -- test, work2 -- test etc., Can I automate this using a command-line script? work |_work 1 |_test |_work 2 ... (2 Replies)
Discussion started by: sharone
2 Replies

4. HP-UX

Symbolic link creation between 2 directories on different machines

I am trying to link 2 directories using: ln -s /net/<hostname>/srcdir/ /net/<desthostname>/dstdir/ I get the following error: ln: /net/<desthostname>/dstdir: Function is not available What is it that i am trying to do wrongly in the above operation? Please use next time code tags (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

5. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

6. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

7. UNIX for Dummies Questions & Answers

List directories with given string, sort by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, which directories name has given particular string. Example: Directories with name "Build" 2. On the output of 1. list the directories by creation date as sort order. I tried with; find . -type d -name "Build*" ... (3 Replies)
Discussion started by: Siva SQL
3 Replies

8. Shell Programming and Scripting

FTP multiple files from multiple directories

I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure.. ./dir1/1/TRADE_LOG*.gz ./dir2/10/TRADE_LOG*.gz ./dir11/12/TRADE_LOG*.gz ./dir12/13/TRADE_LOG*.gz when I do ftp uisng mput from the "." dir I am getting the below given error mput... (1 Reply)
Discussion started by: prasperl
1 Replies

9. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

10. Shell Programming and Scripting

moving directories to new directories on multiple servers

Hi - I am new to unix scripts...I need to move several directories on multiple servers to new directories. (0 Replies)
Discussion started by: mackdaddy07
0 Replies
Login or Register to Ask a Question