If else - grep a string in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If else - grep a string in a file
# 8  
Old 05-11-2010
You can use while loop for this: Smilie

Code:
while read line
do
  if [ "${line}" = "no rows selected" ]
  then
    echo "No session is blocked"
  else
    cat $OUTFILE | mailx -s "[TESTING]Blocking sessions in $ORACLE_SID" $DBA
  fi
exit
done < $OUTFILE

HTH,

Regards,

Praveen
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies

2. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

3. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

4. Shell Programming and Scripting

grep a string in a file

Hi , i'm trying to create a code for the belwo scenario. i have a data in a file file.txt like below. ram dept comp shyam field comp Now i need write a code to find the string which is always 2 lines before the string "comp" Can you please help me in this. Thanks in advance (15 Replies)
Discussion started by: p.bhaskar
15 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. UNIX for Dummies Questions & Answers

How to grep string from nohup.out file

Hi, I have one shell script, which run another one script inside in nohup mode. I want to search one string from the nohyup.out file in the same mail shell script itself .Can anyone help me?? Please find the code below: total_ear=`cd ear ; ls *.ear | wc -l | tr -d ' '` for ear in `cd ear ; ls... (0 Replies)
Discussion started by: ckchelladurai
0 Replies

7. Shell Programming and Scripting

grep string from a file

hi everyone, 1.txt 12 34 56 2.txt 456----aa abc;b;b;b 34;a;a;a;a output is 456----aa 34;a;a;a;a (11 Replies)
Discussion started by: jimmy_y
11 Replies

8. Shell Programming and Scripting

How to grep a string in todays file

Hello guys - I am new to Unix. I am trying to understand how to grep a perticular string in todays file? I am trying this syntax but not getting what I am looking for: % grep `date '+%d/%b/%Y'` For instance there are 2 files generated today with same data. I am trying to find them and... (21 Replies)
Discussion started by: DallasT
21 Replies

9. UNIX for Dummies Questions & Answers

Grep and count the string in a file.

Hi, I have to grep a word 'XYZ' from 900 files ( from 2007 till date), take its count month wise. The output should display month, count , word 'XYZ' . I tried searching the forum for solution but could find any. I would apprieciate if any one can help me asap .... Many Thanks:) (12 Replies)
Discussion started by: vikram2008
12 Replies

10. Shell Programming and Scripting

how to grep for string in log file

Hi Im running a backup scriptwhich creates a log file how do grep for the string in the logfile so the backup script can continue to next stage otherwise it will exit i.e 12:32:53 INF - Client completed sending data for backup 12:33:02 INF - Backup by root on client lonbob04bak using... (4 Replies)
Discussion started by: eb222
4 Replies
Login or Register to Ask a Question
NOTIFY(8)						      System Manager's Manual							 NOTIFY(8)

NAME
notify - HylaFAX user notification script SYNOPSIS
/var/spool/hylafax/bin/notify qfile why jobtime [ nextTry ] DESCRIPTION
bin/notify is the command script invoked by the facsimile server to notify a user about the status of an outbound job. The default notifi- cation script sends the user electronic mail describing the event or action. The arguments are: qfile the pathname of the job description file. why a string that specifies why the user is being notified; one of: Why Notes Meaning done 1 job was completed successfully failed 12 job was not completed rejected 1 job was rejected for specified reasons requeued 2 job was not completed, but was requeued for retry removed 1 job was deleted from the queue killed 1 job was deleted from the queue timedout 1 job could not be sent before kill time expired format_failed 1 document conversion failed no_formatter 1 the document conversion program was not found poll_rejected 12 a polling request was rejected by the remote side poll_no_document 12 a polling request failed because nothing was available poll_failed 12 a polling request failed for an unknown reason blocked 3 job is blocked by concurrent jobs 1 A final job state 2 A transcript of the failed communication is returned to the sender. 3 No emails are sent for the block state, the job has been neither requeued nor done, but remains waiting in the queue for the ability to be sent. jobtime the total transmission time of a successful job or the connect time of a failed request (passed as a string). nextTry the time (passed as a string) at which the next attempt will be made to complete the job. This parameter is passed only if why is ``requeued''. NOTES
The behavior of notify is intended to be customizable via the etc/FaxNotify script, if present. FaxNotify is sourced after the q-file is parsed and all default values are preset. Useful settings for FaxNotify are: WHY is identical to why mentioned above and can be useful in determining under what conditions various settings should take effect. For example, if [ "$WHY" != "done" ]; then RETURNFILETYPE=pdf; fi This would only set RETURNFILETYPE when the job did not complete successfully. RETURNFILETYPE can be set to ``tif'', ``pdf'', ``ps'', or ``original''. If set, this causes notify to return a copy of the submitted documents to the SENDER address along with the notification message. The ``original'' setting uses the format type that was used in the submis- sion. Multiple values may be specified by separating them with whitespace. In that case a separate attachment is created for each filetype. TEMPLATE the template subdirectory to use when sending e-mails. HylaFAX ships with a base set of templates, and some direct translations. To use the German translated templates, set TEMPLATE=de in FaxNotify. This is relative to the base template directory. NOTIFY_FAXMASTER is used to deliver a notification message to TOADDR (which defaults to ``FaxMaster'') that contains technical information about the job. This is useful in allowing the administrator to be aware of any problems before those problems are reported by the users. Possible settings are ``yes'', ``always'', ``no'', ``never'', and ``errors''. If ``errors'' is used then the notification message is only sent to FaxMaster when the job experienced an error. The default is ``no''. The settings of the user in $notify (read from the sendq job file) controls whether the user will get the notification email. If you want to force notification emails, irregardless of the users selection, or force a blocked notification (which is not sent by default), you can set notify="always" which will force the notify script to send the email. FILES
/var/spool/hylafax spooling area /usr/lib/sendmail for delivering mail SEE ALSO
faxq(8), hylafax-server(5), sendq(5) May 8, 1996 NOTIFY(8)