Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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 !!

![]() |
Help Please!!
|
printing a line thru a lo...
|

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