Error while creating directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Error while creating directory
# 1  
Old 07-20-2011
Error while creating directory

Hello Experts
Code:
while read dirlist
do 
   mkdir "$(echo "$dirlist" |\ awk -F\| '{gsub(/(+)/," ",$NF);gsub(/\.atr$/,""); print}')"    
done < /user/Oracle/my_catalog/default/root/bkup/dirnames.txt

where dirname.txt consist of file path details as mentioned below
Code:
/user/Oracle/web/catalog/default_new/root/shared/test19072011/
/user/Oracle/web/catalog/default_new/root/users/administrator/test/
/user/Oracle/web/catalog/default_new/root/users/administrator/test/testing+07202011+abhi/

I want to create directory test19072011, test, testing 07202011 abhi, to be created at mentioned path

pls help where i am missing

Thanks in advance
Smilie

Last edited by Scott; 07-20-2011 at 03:30 AM.. Reason: Code tags, please...
# 2  
Old 07-20-2011
Apart from code tags (again)? The error message, perhaps?
# 3  
Old 07-20-2011
Hello Scottn

i am getting below error
Code:
mkdir: Not a recognized flag: 1

Usage: mkdir [-p] [-m mode] Directory ...

can you please suggest where I am wrong...

Last edited by Scott; 07-20-2011 at 04:08 AM.. Reason: Code tags
# 4  
Old 07-20-2011
What your awk is doing doesn't seem to fully match what your input file looks like (i.e. you're using | as a field separator, when the path is / separated, there is nothing ending with ".atr" - since everything in your input file ends with /, which means $(NF-1) returns the last useful field, not $NF)

Code:
mkdir -p "$(echo "$dirlist" | awk -F/ '{gsub(/\+/," ",$(NF-1));gsub(/\.atr$/,""); print}' OFS=/)"

(I didn't test the mkdir itself, but replacing it with echo gives the output I think you were looking for - assuming it's the whole path you wanted to create)
This User Gave Thanks to Scott For This Post:
# 5  
Old 07-20-2011
thanks a lot scottn
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

creating file and it directory

hello, is there any command that i can use to create a file and also it directory (if not exist)? example: <command> /home/admin/testdir/test1.txt desc: this will create test1.txt under testdir directory. but if testdir is not exist it will be created automatically. thank you... (3 Replies)
Discussion started by: makan
3 Replies

2. Shell Programming and Scripting

creating directory from scripts

Dear All, I have a shell scripts which create a directory and perform moving some files, when the script is kept where it is creating directory then it runs fine , but when the scripts is run where it is supposed to be which is different location then where i am creating directory , scripts... (2 Replies)
Discussion started by: guddu_12
2 Replies

3. UNIX for Dummies Questions & Answers

creating directory in unix

Hi, If i create a directory like with the command ... ~/.ssh so where this folder will be get created in side my home directory ...? what (~) represents here..?:confused: (4 Replies)
Discussion started by: rahul125
4 Replies

4. UNIX for Dummies Questions & Answers

Need help in creating directory

Hello Experts let say we got a line a file named /user/Oracle/my_catalog/default/root/webcat+backup+testing+07192011.atr now i have to create a directory with name webcat backup testing 07192011 by removing + and removing .atr at the given path...can it be possible Please let me know... (4 Replies)
Discussion started by: aks_1902
4 Replies

5. Homework & Coursework Questions

Creating directories within a directory?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Ok i need to create a directory within another directory in one command. I'm already in a directory to. I need to... (6 Replies)
Discussion started by: gangsta
6 Replies

6. Shell Programming and Scripting

Creating Directory

Hi All, As I m very new for Unix, I need to check for a directory and move a file. If Directory is not found, The script should create a directory and move the file. Can any one help here. (7 Replies)
Discussion started by: vikramtk
7 Replies

7. Shell Programming and Scripting

creating a directory tree

Hi all, I'd like to create a directory tree, and define from stdin how many levels deep and how many directories in each level should be created. What I wrote does not work properly:#!/bin/bash #set -x read -p " What root directory? " rootDir && { /bin/rm -R $rootDir; mkdir $rootDir; } ||... (2 Replies)
Discussion started by: NBaH
2 Replies

8. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

9. UNIX for Dummies Questions & Answers

512 Error while creating a directory

Hi, I came across this strange error while creating a directory using mkdir command. The command created the directory but it returned an error code 512. Could some one tell me why this error popped up and what exactly does an error code 512 infer? (11 Replies)
Discussion started by: shreyasjothish
11 Replies

10. UNIX for Advanced & Expert Users

creating directory error

i have create a Directory with "$@#$%" . After creating a Directory, put ls command display "#$%" . Why? (2 Replies)
Discussion started by: lakshmananindia
2 Replies
Login or Register to Ask a Question