grep and exit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep and exit
# 1  
Old 08-17-2011
grep and exit

I have a scenario, where i need to grep for the information and then exit.

i have to grep for "import done" and "bye" from success.log and then update a file with success if these words are present and failure if they are not present.

can any one help with this scenario?
# 2  
Old 08-17-2011
Code:
 
grep "import done" success.log > /dev/null && grep "bye" success.log > /dev/null && echo "Success" > /tmp/log || echo "Failure" > /tmp/log

# 3  
Old 08-17-2011
but in the above scenario it is updating as failure , even though we can find "import done" and "Bye" in success.log
# 4  
Old 08-17-2011
Code:
grep "Bye" success.log

This User Gave Thanks to itkamaraj For This Post:
# 5  
Old 08-17-2011
thnx itkamaraj, it works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Question Grep and exit status

Im being forced to write in perl. I prefer KSH or Expect, so I suppose its time to become more fluent with perl. I have the following problem. I want to loop through Filea and check that each line in Filea is resident in Fileb. Filea contents two four six eight houseboat Fileb... (4 Replies)
Discussion started by: sumguy
4 Replies

2. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies

3. Homework & Coursework Questions

Help with exit, grep, temporary files, awk

1. The problem statement, all variables and given/known data: I do not understand how/why the following code is used. Please do not simply refer me to the man pages since I have already reviewed them extensively. Thank you. exit 2 , exit 3, exit 0 I understand the basics of why the exit... (5 Replies)
Discussion started by: BartleDoo
5 Replies

4. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

5. Shell Programming and Scripting

Exit status of grep

I am trying to get the exit status of grep and test a condition with it, But it does not seem to be working as expected since i am doing something wrong apparently as per grep help Exit status is 0 if match, 1 if no match, and 2 if trouble. My problem is something like this templine - a... (7 Replies)
Discussion started by: prasbala
7 Replies

6. UNIX for Dummies Questions & Answers

trying to grep the first few lines of a continuos script, and exit the script anyidea

Hi. I am trying to extract the output of the first few lines of a continuos sh script. The when i run it, i wont to grep the the first 20 lines of it for an entry and basically do a crtl z out of it or to that effect, and output the results to a text file. I basically want to script... (5 Replies)
Discussion started by: k00061804
5 Replies

7. UNIX for Dummies Questions & Answers

Using exit status of GREP to proceed

Hi I have a script that carries out a "grep" command, and displays the output on screen. What I need to do is utilise the exit status of this grep, so that, for example, if it returns no entries, it asks the user if they want to set up a new user, and if the grep returns an entry, it states... (1 Reply)
Discussion started by: Great Uncle Kip
1 Replies

8. UNIX for Dummies Questions & Answers

grep usage - exit after first occurrence

Hi, Is there any way of using grep (this may be done in awk, not sure?) that I can stop grep'n a file once I have found the first occurrence of my search string. Looking through grep man pages -q will exit without printing the lines after the first match, but I need the output. I have... (5 Replies)
Discussion started by: nhatch
5 Replies

9. Programming

exit(0) versus exit(1)

What is the difference between using exit(0) and exit(1) to exit a program? Which should I use? (9 Replies)
Discussion started by: enuenu
9 Replies

10. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies
Login or Register to Ask a Question