Computing.Net > Forums > Unix > to create subfolders

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

to create subfolders

Reply to Message Icon

Name: Katherine
Date: March 3, 2003 at 09:56:20 Pacific
OS: Unix
Comment:

Hi,

I have a bash script as follows:

--------------
#!/bin/sh
for dir in `find /foo/stats/* -type d`
do
mkdir `find $dir/newfolder/`
Done
--------------

However, there`s a detail that I`d be grateful for help with:

As is, the script creates "newfolder" subfolder for ALL LEVELS of subfolders under "/foo/stats".

However, I`d like to apply it to the FIRST LEVEL OF SUBFOLDERS ONLY, e.g. "foo/stats/folder1", "foo/stats/folder2" BUT NOT TO "foo/stats/folder1/subfolder/", "foo/stats/folder2/subfolder/" and so forth.

Could you please help me modify this script appropriately?

Thanks in advance




Sponsored Link
Ads by Google

Response Number 1
Name: neel
Date: March 3, 2003 at 12:50:25 Pacific
Reply:

Kath,
I think you can try this one..

#!/bin/sh
IFS='
'

ls -ld /foo/stats/* | grep ^d | awk -F" " '{print $9}' > /tmp/temp

for i in `cat /tmp/temp`
do
mkdir $i/NEWFOLDER
done


This is the simplest version :D
njoy ...

~ Neel !!


0
Reply to Message Icon

Related Posts

See More


Help Please!! printing a line thru a lo...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: to create subfolders

how to create a beep sound www.computing.net/answers/unix/how-to-create-a-beep-sound/6312.html

F77 to create bitmaps www.computing.net/answers/unix/f77-to-create-bitmaps/5405.html

how to create shell using 'c' www.computing.net/answers/unix/how-to-create-shell-using-c/3962.html