![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| one simple shell script problem | shaloovia | Shell Programming and Scripting | 7 | 04-21-2009 03:02 PM |
| problem with (probably) grep in shell script | proxy_ | UNIX for Dummies Questions & Answers | 1 | 01-10-2009 05:47 PM |
| simple shell - how to get a parameter typed in a shell script | cmitulescu | Shell Programming and Scripting | 4 | 01-09-2009 08:45 PM |
| simple shell script problem | djt0506 | UNIX for Dummies Questions & Answers | 2 | 12-07-2005 12:00 AM |
| Simple ksh script problem | Warrior232 | Shell Programming and Scripting | 14 | 09-10-2005 12:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Problem with IF - CAT - GREP in simple shell script
Hi all, Here is my requirement I have to search 'ORA' word in out.log file,if it is present then i need to send that file (out.log) content to some mail id.If 'ORA' word is not in that file then i need to send 'load succesful' message to some mail id. The below the shell script is not giving expected result.Please help me to get correct script Code:
if [{cat out.log | grep -c "ORA"} -eq 1]
then
echo out.log
exit 0
else
echo "Load Succes"
fi
Regards Mak Last edited by Neo; 07-16-2009 at 08:26 AM.. Reason: code tags |
|
||||
|
Quote:
Your script is nice. But instead of grep -c "ORA" outlog 1>/dev/null You can use grep -q "ORA" outlog This has the advantage that it will not write any thing on standard out put so no re-direction is required. Also it will exit with success on the first occurance of "ORA", will not search file till the end which is not required. |
|
||||
|
Quote:
|
|
||||
|
Quote:
Thanks Ranjith for the efficient idea ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|