Shell字符串截取——获取oracle group名字
来源:互联网 发布:天下3魍魉捏脸数据 编辑:程序博客网 时间:2024/06/01 10:20
业务背景,在执行oracle文件时,需要授权给相应文件,一边我们用chown -Roracle:oraclegroup xxx,不同服务器oraclegroup名字不相同,怎么样获取呢?
方法:首先,我们可以通过命令groups oracle 获取oraclegroups,格式如下:
oracle : oinstall dba
怎么样获取group 名字(oinstall)?
提供如下方法1:利用awk 获取第三个字符串
oraclegroup=`groups oracle|grep -v grep|awk'{print $3}'`
if [ "$oraclegroup" ="" ]; then
echo "There is no Oracle group"
exit 1
else
chown -R oracle:$oraclegroup $directory
fi
方法二:利用for循环,获取第三个元素
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
0 0
- Shell字符串截取——获取oracle group名字
- Shell字符串截取——获取oracle group名字
- shell脚本小记 ——字符串截取
- Shell脚本——字符串截取
- shell字符串的截取
- Shell 字符串截取方法
- shell字符串的截取
- shell 字符串截取
- shell 字符串的截取
- shell字符串的截取
- shell字符串的截取
- shell 截取字符串
- shell中 字符串截取
- Shell脚本截取字符串
- ---Shell字符串的截取
- shell截取字符串
- shell字符串的截取
- shell字符串的截取
- Java JDBC连接Oracle11.2.0.2(Eclipse)
- Java JDBC连接MySQL(Eclipse)
- Oracle 实例创建脚本
- Oracle DBCA 创建实例
- textarea中禁止换行
- Shell字符串截取——获取oracle group名字
- Cassandra ABC
- Java UDP Socket
- JavaScript 中 setTimeout 的那些事儿
- 数据库期末重点
- C Primer Plus学习 四
- Xcode8 推送收不到消息的解决方法
- android ScrollView 嵌套RecyclerView 解决滑动冲突
- RSA加密