business background, when executing oracle file, need to authorize to the corresponding file, while we use chown-roracle:oraclegroup xxx, different server Oraclegroup The name is different, how to get it?
method: First, we can obtain oraclegroups by command groups Oracle, in the following format :
Oracle:oinstall DBA
How do I get the group name (oinstall)?
provide the following method 1: Use awk to get a third string
oraclegroup= ' groups oracle|grep-v Grep|awk ' {print $} '
If ["$oraclegroup" = ""]; Then
echo "There is no Oracle group"
Exit 1
Else
Chown-r Oracle: $oraclegroup $directory
Fi
method Two: Use A for loop to get the third element
groups= ' Groups Oracle '
Oraclegroup= ""
I=0
for element in $groups
Do
Let i++
if [[I-eq 3]]; Then
Export oraclegroup= $element
Echo$element
Break
Fi
Done
If ["$oraclegroup" = ""]; Then
echo "There is no Oracle group"
Exit
Else
Chown Oracle: $oraclegroup $targetfolder/init_upgrademanagement.sql
Fi
Shell string intercept--Get Oracle Group name