`enter code here` cat /etc/oratab|grep -v "^#"|grep -v "N$"|grep -v +ASM|cut -f1 -d: -s
PROD
DEV
this command give output to two database and I want to select only the PROD part .thankyou for your help!
scripts $ cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
PROD:/u01/app/oracle/product/11.2.0/db_1:Y
DEV:/u01/app/oracle/product/11.2.0/db_1:Y`
iam trying to automate the database start and stop by writing a shell
script and i have two database in server PROD and DEV and the user selects
like the script below .
listdb(){
echo "bases des données dans le serveur :"
db_list=`cat /etc/oratab|grep -v "^#"|grep -v "N$"|cut -f1 -d: -s`
i=1
for DB in $db_list
do
echo $i $DB
i=$(($i+1))
done
read -n1 -p "Select a database to open? [1,2]" doit
case $doit in
1) startdb() ;;
2) startdb() ;;
esac
}
所以我想在用户选择其中之一时将数据库的名称作为参数传递,但是我现在想通了(上面的脚本),所以我正在编写打开和停止数据库的功能。是我不经常使用linux,所以它正在学习执行此projet。
答案 0 :(得分:0)
您可以使用head
:
cat /etc/oratab|grep -v "^#"|grep -v "N$"|grep -v +ASM|cut -f1 -d: -s|head -1