can somebody pls help me understand what is happening here in lines started with headingcopy, linecopy, and sed, don’t fully understand what these headingcopy or linecopy mean as I don’t recognize these commands and, if they are variables, where are they used?…
GetReportParams|grep -iv conn|grep -v "^$"|while read DB_SCHEMA REP_IDX ORG_SHORT_NAME SQL_SCRIPT OUTPUT_FILE_NAME REPORT_NAME REPORT_TYPE OUT_FILE_EXT ORG_NAME MAIN_EMAIL BCC_EMAIL REPORT_GROUP PARAMETERS
do
echo ======================================================================================
export DATE=`date +%Y%m%d -d "1 day ago"`
export OUTPUT_FILE_NAME="${OUTPUT_FILE_NAME}_$DATE.${OUT_FILE_EXT}"
export OUTDIR=$OUTDIR_main/${ORG_SHORT_NAME}/${YEAR_MONTH}
export SCPDIR=/$ORG_NAME/data_extracts/
TMP_FILE_NAME="TMP_RUN_REPORT.txt"
echo Running report for -- $PARAMETERS
# Remove text qualifier character
PARAMETERSSEARCH=`echo $PARAMETERS | tr -d \'`
HeadingCopy=`head -1 $OUTDIR_main/$MAIN_FILE_NAME | tee -a ${OUTDIR_main}/${TMP_FILE_NAME} `
LineCopy=`grep ^"$PARAMETERSSEARCH" $OUTDIR_main/$MAIN_FILE_NAME | tee -a ${OUTDIR_main}/${TMP_FILE_NAME} `
sed 's/[ \t]*$//' ${OUTDIR_main}/${TMP_FILE_NAME} > ${OUTDIR}/${OUTPUT_FILE_NAME}
sed -i 's/[^,]*,//' ${OUTDIR}/${OUTPUT_FILE_NAME}
#cat ${OUTDIR}/${OUTPUT_FILE_NAME}
rm ${OUTDIR_main}/${TMP_FILE_NAME}
rsync -a ${OUTDIR}/${OUTPUT_FILE_NAME} oracle@grnwebreports2:$SCPDIR
done
Thanks!
Leo
copies the first line from the file $OUTDIR_main/$MAIN_FILE_NAME to the variable HeadingCopy and also redirects(appends) the output to a file ${OUTDIR_main}/${TMP_FILE_NAME}
copies the line which start with the string that is present in the variable PARAMETERSSEARCH and
also redirects(appends) the output to a file ${OUTDIR_main}/${TMP_FILE_NAME}
second sed will replacs every line the data in the file from the first character till it encounters a “,”