I don't have extensive experience in ksh and am having a rough time with a multi-line variable in a script I'm trying to revise. Basically, I'm looking to strip out the first part of the resulting output up until some "CAMP" text and keep whatever is after that. The result gets sent in an email. What I've tried doesn't seem to work though.
Here's the multi-line part. Variables are set prior. I've removed the exact SQL.
$ORACLE_HOME/bin/sqlplus -s << EndOfSql > ${LOG_FILE}
$USERPASS@$ORACLE_SID
SQL goes here with some other SET stuff
/
EXIT;
EndOfSql
This is then eventually used like this to send the email to the email address in MAIL_ID:
mailx -s "Email subject line"\
$MAIL_ID < $LOG_FILE;
As mentioned, what I'm trying to do is strip out everything in the result up until some "CAMP" text in the heredoc result from the SQL output. I've tried things like this, but am having a tough time understanding heredoc and variables since there are so many methods out there:
CNTNT=${LOG_FILE#*CAMP}
mailx -s "Email subject line"\
$MAIL_ID < $CNTNT;
Any recommendations or resources you could please point me to? It'd be sincerely appreciated.
As mentioned in my previous comment, it looks like you're trying to capture output into a variable, but are actually sending it into a file.
As an alternative, this might work: