Hey guys, I'm fairly new at unix shell scripting and I have a quick question.
Quick overview I devolped a script where I generate a file ..and I want to grep any time greater than 30 minutes.
What i do is runa command to generates the below and puts it into a file:
I run
./ggsci << endit >$AUDIT_DIR/check_oracle_output_$ORACLE_SID.out
the file check_oracle_output_$ORACLE_SID.out contains info below
Program Status Grp lag TimeChkpt
MANAGER
EXTRACT RUN EMMP 00:00:00 00:00:06
EXTRACT RUN PMMP 00:00:00 00:00:06
REPLICAT RUN RMDRA 00:00:00 00:00:00
REPLICAT RUN RMDRB 00:00:00 00:00:06
What I wanted to do was grep the file for anytime greater than 00:30:00 and then i was going to set up an if clause and send myself an e-mail
i was told that grep wont work but i can use
target='! ! ! ! 00:00:30'{ echo; echo "$target"; cat 'the-file.txt'; } | sort -t' ' -k5,5 -s | sed '1,/! ! ! !/d'
so when i do
target='! ! ! ! 00:00:30'{ echo; echo "$target"; cat 'check_oracle_output_$ORACLE_SID.out '; } | sort -t' ' -k5,5 -s | sed '1,/! ! ! !/d'
I get an error : ./testgg.ksh[31]: syntax error at line 42 : `}' unexpected
thank you.
Is target similar to grep because want I want to do is something like
target='! ! ! ! 00:00:30';{ echo; echo "$target"; cat 'check_oracle_output_$ORACLE_SID.out '; } | sort -t' ' -k5,5 -s | sed '1,/! ! ! !/d'
if [ $? -eq 0 ]
then
echo "agent was down" > $AUDIT_DIR/file1.txt
fi
Now what im trying to do is basically see if the return status for the above
if it is 0 then echo "time is greater than 30" > $AUDIT_DIR/file1.txt
so in other words could i do
target='! ! ! ! 00:30:00'; { echo; echo "$target"; cat '$AUDIT_DIR/check_oracle_output_$ORACLE_SID.txt';}| sort -t' ' -k5,5 -s | sed '1,/! ! ! !/d'
if [ $? -eq 0 ]
then
echo "time is greater than 30" > $AUDIT_DIR/file1.txt
fi
So if the target command does succeeds with something above 30 then the text time is greater than 30 would be inputted into the file1.txt...