1. 命令收集版本信息
# 创建数据收集脚本文件 OPER_FILE=${EXECUTE_ID}_oper.sh if [[ "${OPER_USER}" = "${USER}" ]]; then echo "${PATCH_HOME}/opatch lsinventory > ${MODULE_OUT_DIR}/${OPER_USER}.info" > ${OPER_FILE} else echo "su - ${OPER_USER} -c \"${PATCH_HOME}/opatch lsinventory\" > ${MODULE_OUT_DIR}/${OPER_USER}.info" >> ${OPER_FILE} fi sh -x ${OPER_FILE} &
2. 格式化输出
grep -E $'Patch +[0-9]+.*\nUnique Patch.*\nPatch description.*\nCreated on.*' ${MODULE_OUT_DIR}/${OPER_USER}.info | tr '\n' ' ' | sed -r 's/(Patch +[0-9]+ +:)/\n\1/g' | sed -r 's/Patch +([0-9]+) +: +applied +on +(.*) +Unique.*"(.*)" +Created +on +(.*)hrs +PST8PDT/\1##\4##\2##\3/g'