Visit Our UNIX and Linux User Community


extract DB version from oratab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract DB version from oratab
# 1  
Old 09-28-2009
Question extract DB version from oratab

My oratab has the following contents

RMD10203:/u01/app/oracle/product/10.2.0RMD10203:Y
RMDIDEVL:/u01/app/oracle/product/11.1.0RMDIDEVL:Y
RMDIDES:/u01/app/oracle/product/11.1.0RMDIDES:Y

I have a script for which I pass the oracle sid as the parameter
I need to extract the version of the oracle home from the oratab.
I have tried
grep $ORACLE_SID /var/opt/oracle/oratab|grep -v \# |cut -d/ -f6|awk -F":" {'print $1'}
and get "11.1.0RMDIDES" as the output of the command, how do I just get the version like 11.1.0 as the output

Thanks in advance,AK
# 2  
Old 09-28-2009
You could try:
Code:
sed -n "s#${ORACLE_SID}.*/\(.*\)${ORACLE_SID}.*#\1#p" /var/opt/oracle/oratab

or shorter, but not as exact:
Code:
sed -n "s#.*/\(.*\)${ORACLE_SID}.*#\1#p" /var/opt/oracle/oratab


Last edited by Scrutinizer; 09-28-2009 at 06:24 PM..
# 3  
Old 09-28-2009
IN Just changing your code you can change your -F":" -F"R" so you would have
Code:
grep $ORACLE_SID /var/opt/oracle/oratab|grep -v \# |cut -d/ -f6|awk -F"R" {'print $1'}

# 4  
Old 09-28-2009
Or you can use Perl -

Code:
grep $ORACLE_SID /var/opt/oracle/oratab | perl -lne '/.*\/([\d.]+)/ && print $1'

tyler_durden
# 5  
Old 09-28-2009
Code:
$ grep $ORACLE_SID /var/opt/oracle/oratab|sed 's#.*\([0-9][0-9]\.[0-9]\.[0-9]\).*#\1#'
10.2.0
11.1.0
11.1.0

# 6  
Old 09-29-2009
another way..
Code:
-bash-3.2$ grep -o "[0-9]\{2\}.[0-9].[0-9]" file
10.2.0
11.1.0
11.1.0

# 7  
Old 09-29-2009
Thnx guys, solved my problem

Previous Thread | Next Thread
Test Your Knowledge in Computers #934
Difficulty: Medium
The C standard library does not specify any specific resolution, epoch, range, or datatype for system time values.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract Oracle home from Oratab and compare values

Friends, I'm trying to do below in ksh script, while requesting user to provide src_db and dest_db values 1. Extract src_db and dest_db Oracle home from oratab file 2. Don't find db if it starts with comment (#) 3. Compare both values 4. Message success or exit with error if they don't... (0 Replies)
Discussion started by: homer4all
0 Replies

2. Red Hat

OS version and Firmware version

Guys, How to find OS version and firmware version in LINUX? Like in AIX. uname -a will show me the version 5.3, 6.1,7.1. lsmcode -c will show me - system firmware image as SF240_417. What are the similar commands in Linux. I checked uname -a and cat /etc/release. uname... (1 Reply)
Discussion started by: ElizabethPJ
1 Replies

3. Shell Programming and Scripting

Copy a file from directroy/ prior version to the directory/ new version

How to copy a file from directroy/ prior version to the directory/ new version automatically. (4 Replies)
Discussion started by: roy1912
4 Replies

4. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

5. UNIX for Advanced & Expert Users

Advanced Search * View * Edit JAVA version to WORK in GLASSFISH Forum topic JAVA version

Would like to confirm the ff. I got confused actually with the version I needed to download that will work on glassfish 3.0.1 a. Debian Squeeze (HP DL360). Need to use java version6 On Debian, I did apt-get install sun-java6-jdk. So when I check it's java version "1.6.0_22" Java(TM) SE... (1 Reply)
Discussion started by: lhareigh890
1 Replies

6. Solaris

Migrate unix version 8 to version 9

i have a program writing in PRO C which currently running in unix version 8 tie with oracle 8i, but in the future company gonna migrate this OS to version 9. Anything i have to prepare for my PRO C program to run in unix version 9? or anything would that impact my program couldn't run well? what... (2 Replies)
Discussion started by: lsy
2 Replies

7. HP-UX

What is my Version

Hi, This is my HP-UX version, hpprod::root>uname -a HP-UX hpprod B.11.11 U 9000/800 1110164401 unlimited-user license hpprod::root> but I've already patch with, PHSS_30101 1.0 Support Tool Manager Dec 2003 PHSS_30170 B.11.11.18 ... (1 Reply)
Discussion started by: aldosfox
1 Replies

8. UNIX for Dummies Questions & Answers

What OS version am I on?

I'm trying to figure out the exact version of the AIX box I'm on. Like whether it's 5.1 or 5.2. I tried lsconf and smit but they didn't give the answer. Does anyone know a command that returns this value? I don't have root access. (3 Replies)
Discussion started by: rein
3 Replies

9. UNIX for Dummies Questions & Answers

VERSIOn

Hi, I would like to know, how do I findout what version UNIx OS my computer is using? Is there a particular command I type to do this? Please advise. Thanks (1 Reply)
Discussion started by: huhuloa
1 Replies

10. UNIX for Dummies Questions & Answers

what version am I using?

Hi Im new here and pretty new to Unix. Just a couple of questions How can I tell what version of Unix I'm running? and Also I hope this makes sence, when writting scripts/programmes does it matter what Im writting it in? ie what shell? Or is it just identical whatever shell Im... (1 Reply)
Discussion started by: Loaded Gun
1 Replies

Featured Tech Videos