Error while creating directory

Hello Experts

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

/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
:confused:

Apart from code tags (again)? The error message, perhaps?

Hello Scottn

i am getting below error

mkdir: Not a recognized flag: 1

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

can you please suggest where I am wrong...

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)

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)

thanks a lot scottn