Create folders using masklist


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create folders using masklist
# 1  
Old 10-26-2011
Create folders using masklist

hello there,

I have a file called foldermasklist.txt
have
Code:
Aayush 1 source1/checksum
Aayush 0 source2/checksum
flexing  1  source1/source2/checksum
flexing  1  time1/checksum

in the format
Code:
<parentfolder><flag><subfolders>

script needs to read the flag if it's 1 then folder needs to create like
Code:
mkdir -p <parentfolder><flag><subfolders>

if's 0 then skip it.
there can be many parent and subfolders but depdning on flag it has to be decided to create or not .

can anyone help me out.

Regards,

Moderator's Comments:
Mod Comment Having 178 posts you should know better how to use code tags and not just paste code, data and descriptive text all in one block together!
Use code tags <- click the link!

Last edited by zaxxon; 10-26-2011 at 09:51 AM.. Reason: code tags, see PM
# 2  
Old 10-26-2011
What have you tried so far?
# 3  
Old 10-26-2011
Do really you want <flag> in the created path?

Anyway, you could do something like:
Code:
while read PARENT FLAG FOLDERS
do
   if [ "${FLAG}" == "1" ]
   then
      mkdir -p "${PARENT}"/"${FOLDERS}"
   fi
done < foldermasklist.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create 2 different path folders?

Hi all, I am new to this forum. A_NAME=$5 DEPT="abc" DEPT_NAME="cdf" echo " Name:" $A_NAME | tee -a ${LOG_FILE_NAME} echo "dept :" $DEPT | tee -a ${LOG_FILE_NAME} echo "dname :" $DEPT_NAME | tee -a ${LOG_FILE_NAME} echo "parse_parms done" | tee -a ${LOG_FILE_NAME}... (11 Replies)
Discussion started by: Boost
11 Replies

2. Shell Programming and Scripting

Urgent- shell script to create sub folders

Hi All, Could any one help me with a shell script which will create different sub folders in a folder and of which the sub folders names should be taken from a text file. Thanks (1 Reply)
Discussion started by: chetansingh23
1 Replies

3. UNIX for Dummies Questions & Answers

script to create folders

hi again, having an issue with the code here because it doesnt work :D can someone point what and how to change, please. #!/bin/bash #create directory mylabs, inside create 6 directories named by user. DIR1="$1" DIR2="$2" if ; then echo -n " there is a folder named mylabs, what... (1 Reply)
Discussion started by: me.
1 Replies

4. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

5. Shell Programming and Scripting

Some manipulations with files and folders. (loop, find, create and remove)

Hello! I need to realize such task. 1. In my user's home dir I have folder1; 2. In folder1 I have some (various count) subfolders with random names; 3. In these subfolders I have one file anyname.pdf (various name in each subfolder) and file content.txt (constant name in each subfolder) ##... (7 Replies)
Discussion started by: optik77
7 Replies

6. Shell Programming and Scripting

Simple Script to create folders

Hi I want to write a small script that will create folders named from `AAAA' all the way to `ZZZZ'. That is: `AAAA' `AAAB' `AAAC' ... `AABA' `AABB' `AABC' ... `ABAA' `ABAB' `ABAC' ... `ABBA' ... `ZZZZ' (4 Replies)
Discussion started by: ksk
4 Replies

7. Shell Programming and Scripting

create folders until conditions met

Hi, I want to create 10 folders, starting from TEST001 till TEST010, after folder TEST010 is created the script should exit. Thanks in advance (1 Reply)
Discussion started by: bprabhukumar
1 Replies

8. Shell Programming and Scripting

Need to create a script to show what files in what folders

Hi everyone, I'm stuck with this scenario where our system creates files every night and puts them in several folders according from whom it came from. I have managed to create a script which will list the folders in one column and the files that are in them in another column, now my problem... (6 Replies)
Discussion started by: kumaran21
6 Replies

9. Shell Programming and Scripting

how to create symbolic link between folders.....

hi champs, i have folders structure up to log is there , which is as below, app | |---version-4.1 | |----bin | | | | | |-----a.sh | | |-----b.sh | | | |----log | | \---version (symbolic link to version-4.1) but i want to create another folder... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

10. Shell Programming and Scripting

How to create folders/subfolders using shellscript

Hi, Can any one help me how to create folders using shellscript.My requirement is: FolderName: Main/Main1 :Main/Main2 :Main/Main3 underSubFolder : Main1/A :Main1/B :Main1/C underSubfolder: A/A1 ... (2 Replies)
Discussion started by: ram2s2001
2 Replies
Login or Register to Ask a Question