I get the below error on running above command from shell script in CYGWIN.
Error:
sed: -e expression #1, char 1: unknown command: `,'
IF I ran command in cmd:
$ sed -n "8937,8946 p" "/cygdrive/c/TEMP/temp_oracle/alert_cert1_copy.log" | egrep -e "ORA-|Shutting down"
It works OK - Result:
ORA-1623 signalled during: ALTER DATABASE DROP LOGFILE GROUP 1...
Shutting down database
NOTE: 8937
& 8946
are the line numbers in text file - where it is needed to check the patterns. Searching must be between these lines.
IF I run the command in from shell script - the above error appears.
Shell Script:
export alert_file="/cygdrive/c/TEMP/temp_oracle/alert_cert1_copy.log"
export alert_output="/cygdrive/c/cygwin64/home/alert_out.log"
function searchAlertByFilterLN() {
#err1=$(sed -n "${lastLineNum},${totLines} p" $alert_file | egrep -e "ORA-")
err1=$(sed -n "8937,8946 p" $alert_file | egrep -e "ORA-|Shutting down")
if [ -n "$err1" ]; then
echo -e "Errors found:" > $alert_output
echo ------------ >> $alert_output
sed -n "8937,8946 p" $alert_file | egrep -e "ORA-|Shutting down" >> $alert_output
echo "" >> $alert_output
echo "" >> $alert_output
echo -e "Check the details of the errors below. (Details means the surroundig lines of the error message only)" >> $alert_output
echo "-------------------------------------" >> $alert_output
sed -n "8937,8946 p" $alert_file | /usr/bin/egrep -A 5 -B 2 "ORA-|Shutting down" >> $alert_output
fi
}
searchAlertByFilterLN --
echo "function was executed"
With regards!