Shell字符串截取——获取oracle group名字
来源:互联网 发布:ftp服务器软件绿色版 编辑:程序博客网 时间:2024/05/22 06:19
业务背景,在执行oracle文件时,需要授权给相应文件,一边我们用chown -Roracle:oraclegroup xxx,不同服务器oracle group名字不相同,怎么样获取呢?
方法:首先,我们可以通过命令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字符串的截取
- [leetcode][stack] Min Stack
- leetcode刷题,总结,笔记,备忘。136
- 禁止所有Activity横屏
- 在Android里用DOM方式解析XML文件
- JSP学习笔记(一):tomcat7.0.6配置
- Shell字符串截取——获取oracle group名字
- C++中的static关键字
- Practice.3_YU 求日期和时间
- Sublimetext查看代码的编码方式
- Android中如何将原生程序向stdout和stderr的输出重定向到logcat
- 最大似然估计、最大后验估计和贝叶斯估计的关系
- Windows Phone 8.1中的.xaml文件开头那些奇怪的定义
- Practice.3_YU My Queue
- 黑马程序员——String类与this关键字