Help with create multiple directories under diff file systems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with create multiple directories under diff file systems
# 1  
Old 08-19-2014
RedHat Help with create multiple directories under diff file systems

Hi,

Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl.
../ORCL_data01/oradata/orcl/data.
../ORCL_data01/oradata/orcl/redo.

Script :-
=========
Code:
for dir in `ls -d /${ORACLE_SID}_data[0-9][0-9]`
do
mkdir -p $dir/oradata/${ORACLE_SID}/ctrl
mkdir -p $dir/oradata/${ORACLE_SID}/data
mkdir -p $dir/oradata/${ORACLE_SID}/redo
done

I'm getting the following error :-
===============

Code:
ls -d /${ORACLE_SID}_data[0-9][0-9]
+ ls -d '/ORCL_data[0-9][0-9]'
ls: cannot access /ORCL_data[0-9][0-9]: No such file or directory

Directories
===========
Code:
/ORCL_data01
/ORCL_data02
/ORCL_data03
/ORCL_index01
/ORCL_index02
/ORCL_redo01
/ORCL_redo02
/ORCL_archive01


========

Thanks

Last edited by Don Cragun; 08-19-2014 at 05:34 PM.. Reason: Add CODE tags.
# 2  
Old 08-19-2014
There is no need to create a sub shell and call ls the shell can expand the files for you.

Try:

Code:
for dir in /${ORACLE_SID}_data[0-9][0-9]
do
  if [ -d "$dir" ]
  then
      mkdir -p "$dir/oradata/${ORACLE_SID}/ctrl"
      mkdir -p "$dir/oradata/${ORACLE_SID}/data"
      mkdir -p "$dir/oradata/${ORACLE_SID}/redo"
   else
      echo "/${ORACLE_SID}_dataNN dir(s) not found"
      exit 1
   fi
done

# 3  
Old 08-19-2014
Thanks a lot for the reply...

Code:
for dir in /${ORACLE_SID}_data[0-9][0-9]
do
  if [ -d "$dir" ]
  then
      mkdir -p "$dir/oradata/${ORACLE_SID}/ctrl"
      mkdir -p "$dir/oradata/${ORACLE_SID}/data"
      mkdir -p "$dir/oradata/${ORACLE_SID}/redo"
   else
      echo "/${ORACLE_SID}_dataNN directories do not exist"
      exit 1
   fi
done

But i'm still getting same error...

Error :-
==============

Code:
+ [ -d '/ORCL_data[0-9][0-9]' ]
+ echo '/ORCL_dataNN directories do not exist'
/ORCL_dataNN directories do not exist
+ exit 1

===============

Last edited by Don Cragun; 08-19-2014 at 05:37 PM.. Reason: Add CODE tags.
# 4  
Old 08-20-2014
This is not an error, but perfect execution of your script.
Are you sure the directories exist in the / (root) directory? Post the output of
Code:
ls -d /${ORACLE_SID}_data[0-9][0-9]

or, if that fails, the output of
Code:
ls /

# 5  
Old 08-20-2014
Note that mkdir with or without -p does not create new filesystems. The directories created by mkdir will always be in the same filesystem as the directory in which the parent directory resides.

To create new filesystems, you need mount, not mkdir.
# 6  
Old 08-20-2014
Code:
for dir in /${ORACLE_SID}_data{01,02,03}
do

# 7  
Old 08-20-2014
RudiC, Thanks for your Reply ..The directory do exists.
Code:
[oracle@db1 ~]$ ls -d /ORCL_data[0-9][0-9]
/ORCL_data01
[oracle@db1 ~]$

[oracle@db1 /]$ ls /
app  bin  boot  cgroup  dev  etc  home  lib  lib64  lost+found  media  misc  mnt  net  opt  ORCL_archive01  ORCL_data01  ORCL_index01  ORCL_redo01  proc  root  sbin  selinux  srv  sys  tmp  usr  var
[oracle@db1 /]$

2) Thanks MadeInGermany for your reply..I have tried that option and it did not work too..
Code:
for dir in /${ORACLE_SID}_data{01,02,03}
do
  if [ -d "$dir" ]
  then
      mkdir -p "$dir/oradata/${ORACLE_SID}/ctrl"
      mkdir -p "$dir/oradata/${ORACLE_SID}/data"
      mkdir -p "$dir/oradata/${ORACLE_SID}/redo"
   else
      echo "/${ORACLE_SID}_dataNN directories do not exist"
      exit 1
   fi
done


+ [ -d /pd1mds_data01 ]
+ echo '/pd1mds_dataNN directories do not exist'
/pd1mds_dataNN directories do not exist
+ exit 1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Scan and create file systems in new LUNs

Hi I have a system running uname -a Linux cmoveldb02 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux and I was told by the NetApp Admin that he has provided 5 LUNs of 1Tb, 200Gb and remaining 3 of 300Gb, but I am not able to see the new LUNs. I have... (4 Replies)
Discussion started by: fretagi
4 Replies

2. UNIX for Advanced & Expert Users

Diff on remote servers file systems

Iam trying to compare two file systems on two hosts basically to check them to be in sync I dont have rsync so trying to use diff Let me know how to do it.... Thanks (3 Replies)
Discussion started by: baanprog
3 Replies

3. Shell Programming and Scripting

Single script to create multiple directories

Hi , I want a script to create a directories at different locations. suppose i am on home/path/zone1. I want to create a directory of current month in this location. Then i want to create the same current month directory in home/path/zone2.like this for 9 diffrent zones. I can do this... (4 Replies)
Discussion started by: sv0081493
4 Replies

4. UNIX for Dummies Questions & Answers

Create multiple directories with awk

Hello all. Newbie here. In a directory, I have 50 files and one additional file that is a list of the names of the 50 files. I would like to create a directory for each of the 50 files, and I need the 50 directory names to correspond to the 50 file names. I know this can be done by running... (6 Replies)
Discussion started by: Zeckendorff
6 Replies

5. Shell Programming and Scripting

How to create tgz file for all the directories in one time?

Hi, On server there is an one folder . which contains sub folder Eg - TEST folder contains test1, test2, execr ,tt (folder). also includes some text file like abc.txt psp.txt gg.log. here iwant to create tgz file for all the folders and file in one time. I know the command... (1 Reply)
Discussion started by: aish11
1 Replies

6. Shell Programming and Scripting

Umount an entire device with multiple file systems

I wish to umount in a bash script a specific device (/dev/sdb for example) that has multiple mounted file systems. how will I go about doing this? Also is there a way to get a list of removable devices currently connected and offer the user a selection of them? (The devices themself not their... (2 Replies)
Discussion started by: temp4746
2 Replies

7. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

8. UNIX for Dummies Questions & Answers

Create directories from a sql file?

Hi, I have a sql file which has CREATE and INSERT commands in it. Basically, inside this file, a table will be created and the data will be inserted into the table. I was wondering if there is a way for me to create directories from this file? Thanks in advance (4 Replies)
Discussion started by: tezarin
4 Replies

9. UNIX for Advanced & Expert Users

File Compare and Create New File with Diff

I need to compare File A with File B and create FILE C with the difference record only. What I mean is File A has 3 records and File B has 4 records, so FILE C will only have 1 record (becuase that record is in FILE B and not in File A). Hope I am making sense. The data layout is that each data... (7 Replies)
Discussion started by: guiguy
7 Replies

10. Shell Programming and Scripting

Create Folder in Multiple Directories

Hi, I am trying to figure out how to have a folder created in multiple directories. For example /home is where we have over 1500 staff members directories, the staff members name is the name of directory under /home. I need to have a folder called "Desktop" created in every staff members directory.... (15 Replies)
Discussion started by: Stud33
15 Replies
Login or Register to Ask a Question