The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to create a list of entries without vi mpc8250 Shell Programming and Scripting 3 02-13-2008 12:56 AM
Create a list of files that were modified after a given date. rkka UNIX for Dummies Questions & Answers 4 01-22-2008 02:12 AM
Read words from file and create new file using K-shell. bsrajirs Shell Programming and Scripting 4 06-01-2007 09:15 AM
How create a large list of document ids in VI ruben7566 Shell Programming and Scripting 1 04-05-2006 07:16 AM
How to create a dynamic list? nir_s Shell Programming and Scripting 4 01-14-2005 09:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-11-2006
Registered User
 

Join Date: Sep 2006
Posts: 5
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
Reply With Quote
Forum Sponsor
  #2  
Old 09-11-2006
Sergiu-IT's Avatar
Registered User
 

Join Date: Mar 2005
Location: Transilvania
Posts: 125
I guess you need something like this:

Code:
for directory in `cat directories.txt`
do
    mkdir directory;
done
Reply With Quote
  #3  
Old 09-11-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
Try:
Code:
#! /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
Reply With Quote
  #4  
Old 09-11-2006
Registered User
 

Join Date: Sep 2006
Posts: 5
Well what i need is multiple creat for dir

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
Reply With Quote
  #5  
Old 09-11-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
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?
Reply With Quote
  #6  
Old 09-12-2006
Registered User
 

Join Date: Aug 2006
Posts: 4
something like this, maybe?

awk '{print "mkdir "$1}' file | sh
Reply With Quote
  #7  
Old 09-12-2006
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 988
A solution that doesn't need the combined horsepower of awk and a new shell is probably more efficient.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0