how to create new dir fro a file list

Hi,

What will be the best way to do the follwing:
i have a file calld dir.list
/cav
/cav/brif
/usr/main
/cat

i want to run a script that will take each of the item in the file and create a new dir in a location that i'll choose

it nee to do mkdir cav
mkdir cav
cd cav
mkdir brif
......

thanks

I guess you need something like this:

for directory in `cat directories.txt`
do
    mkdir directory;
done

Try:

#! /bin/ksh

curdir=`pwd`

while read path; do
if [[ ! -d $curdir$path ]]; then
mkdir -p $curdir$path
fi
done < dirlist

Note: Above code is as per your given sample which has a "/" at the begining of each line.

Regards,
Tayyab

i need to create the all path

/cav/usr/mmm/t

i need to create /cav
after that create the /cav/usr
and then /cav/usr/mmm

how can i do that from a script that will read the dir to creates from a file that will look like that:
/cav/usr
/benny/ddd/t
/usr/clear
/cacac/hhttt/to
.....

Thanks a Mil

Have you tried to use shereenmotor's script? Does it do what you want? If it does not, then can you explain where it is failing?

something like this, maybe?

awk '{print "mkdir "$1}' file | sh

A solution that doesn't need the combined horsepower of awk and a new shell is probably more efficient.

try this

for dire in `cat directory.txt`
do
   mkdir -p ${dire}
done

many thanks

This is a UUOC. That's functionally identical to this earlier example, but yours launches a whole extra process. It's also limited to a list the shell's maximum argument size or smaller, where the earlier one has no such limit.