命令收集Oracle软件版本信息
# 1. 创建数据收集脚本文件
[[ -z "${OPER_USER}" ]] || OPER_USER='oracle'
OPER_FILE=/tmp/oper.sh
if [[ "${OPER_USER}" = "${USER}" ]]; then
echo "${ORACLE_HOME}/OPatch/opatch lsinventory > /tmp/${OPER_USER}.info" > ${OPER_FILE}
else
echo "su - ${OPER_USER} -c "${ORACLE_HOME}/OPatch/opatch lsinventory" > /tmp/${OPER_USER}.info" >> ${OPER_FILE}
fi
nohup sh -x ${OPER_FILE} >/dev/null 2>&1 &
格式化输出
grep -E $'Patch +[0-9]+.*
Unique Patch.*
Patch description.*
Created on.*' /tmp/${OPER_USER}.info | tr '
' ' ' | sed -r 's/(Patch +[0-9]+ +:)/
1/g' | sed -r 's/Patch +([0-9]+) +: +applied +on +(.*) +Unique.*"(.*)" +Created +on +(.*)hrs +PST8PDT/1##4##2##3/g'