![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regarding Shell Scripting | anilkarikkandar | UNIX for Dummies Questions & Answers | 3 | 11-19-2006 09:26 PM |
| HELP PLS!! Shell Scripting!! | Mary_xxx | Shell Programming and Scripting | 9 | 09-16-2006 03:52 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 05:12 AM |
| something else on shell scripting | master_6ez | Shell Programming and Scripting | 1 | 11-21-2004 08:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a file in /etc/ called oratab
how do i read the file # *:/apps/oracle/product/8.1.6ctmdev01:N # *:/apps/oracle/product/8.1.6ctmdev01:N QBIP:/apps/oracle/product/8.1.6qbip01:Y QBID:/apps/oracle/product/8.1.6qbid01:Y QBIT:/apps/oracle/product/8.1.6qbit01:Y and read QBIP QBID QBIT into Oracle_value variable and pass that variable into my shell script?? the purpose is to run that 1 script on 3 instances?? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
try this...
Oracle_value=`cut -d : -f 1 /etc/oratab | grep '[A-Z]+' | sed 's/\n/ /'` this will put "QBIP QBID QBIT " in Oracle_value Vishnu. |
|
#3
|
|||
|
|||
|
Vishnu
thanks for the info the problem is to avoid # or * and how do i read thru the file?? # *:/apps/oracle/product/8.1.6ctmdev01:N # *:/apps/oracle/product/8.1.6ctmdev01:N QBIP:/apps/oracle/product/8.1.6qbip01:Y QBID:/apps/oracle/product/8.1.6qbid01:Y QBIT:/apps/oracle/product/8.1.6qbit01:Y Jigar |
|
#4
|
||||
|
||||
|
How about something like this:
Code:
#! /usr/bin/ksh
IFS=:
exec < /etc/oratab
while read Oracle_value junk ; do
firstchar=${Oracle_value%${Oracle_value#?}}
[ $firstchar = '#' ] && continue
echo Oracle_value = $Oracle_value
done
exit 0
|
|
#5
|
|||
|
|||
|
Oracle_value=`cut -d : -f 1 /etc/oratab | grep '[A-Z]+' | sed 's/\n/ /'`
in this cut will isolate the first column in all lines using : as separator and [A-Z]+ in grep ensures that you dont read the columns having # etc and sed replace newlines with spaces. If you want a loop in which you can pass the content of whole lines having QBIP etc. You may try this.. while i in `grep '^[A-Z]+:.*$' /etc/oratab` do echo $i done this will echo only those lines beginning with all caps and ending with a : . So effectively isolating those lines containing QBIP etc. |
|
#6
|
|||
|
|||
|
sorry..
replace "while i in" in my above reply with "for i in"... thank you! Vishnu. |
|
#7
|
|||
|
|||
|
How about this
awk -F":" '/^[A-Z]/ { print $1}' /<reg exp>/ will remove unwanted lines.
__________________
Thanks Vikas Srivastava |
|||
| Google The UNIX and Linux Forums |