Recursive search for string in file with Loop condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recursive search for string in file with Loop condition
# 1  
Old 05-07-2013
Recursive search for string in file with Loop condition

Hi,

Need some help...

I want to execute sequence commands, like below

test1.sh
test2.sh
...etc

test1.sh file will generate log file, we need to search for 'complete' string on test1.sh file, once that condition success and then it should go to test2.sh file, each .sh scripts will take longer time, so that i want to put condition there that string "complete" should get in the log, then pass to next script.

Note: I tried with && and ;, but it doesn't work in my case as log has to generate and wait for some time. i dont know why its not wrking, so i thought to go for loop condition on log file, based on that it should go sequential.

Some one help on this how to get this.

Thanks
# 2  
Old 05-07-2013
Your situation is a bit strange, but cannot be improved without knowing more about the test1.sh.
Here is a proposal for a strange solution on a strange problem:
Code:
test1.sh &
tail -f logfile_from_test1.sh | awk '/complete/ {exit}'
test2.sh &
tail -f logfile_from_test2.sh | awk '/complete/ {exit}'
test3.sh
...

This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 05-08-2013
Will test1.sh stop/exit after writing "complete" or will it continue to exist? Do you have access to the scripts so you can modify them?
# 4  
Old 05-08-2013
I just had a thought.

Although the previous *.sh technically exits when the newer running *.sh starts and the previous *.sh opens a file but fails to close it correctly will the garbage collection clear up the memory loss or will this become a memory leak?

Again just a thought...
# 5  
Old 05-08-2013
Quote:
Originally Posted by RudiC
Will test1.sh stop/exit after writing "complete" or will it continue to exist? Do you have access to the scripts so you can modify them?
test1.sh script will take longer time and sometimes its not coming out to proceed next script, so once "complete" script found in the log of test1, it should go to test2.sh. I have full access & can modify...but only thing is that its not working.
# 6  
Old 05-10-2013
If you don't like MadeInGermany's proposal, here's two thoughts you may want to consider:
1) split test1.sh in at least two parts - one that does the task you wait for (e.g. write "complete") , and the other to do the rest.
2) have test1.sh write a file, or better, a named pipe when it completes the task you wait for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help search multiple condition from a file.

OS: window 7 shell : korn shell I have 2 file , i'm need grep data according File_1 from file 2. File_1 CAL_ENAB_N_4_ $2N12743_29 +12V File_2 NODE CAL_ENAB_N_4_ PINS 21548; PROBES P1465 3651, 46900 tn2700.1 LWT; WIRES (6 Replies)
Discussion started by: kttan
6 Replies

2. UNIX for Beginners Questions & Answers

Loop through the folders and search for particular string in files

Hello, Opearting System Environment : HP Unix B.11.31 U I look for script to On specific folders list On specific filelist Search for given string For Example : r48_buildlib.txt contains wpr480.0_20161027 wpr480.0_20161114 wpr481.0_20161208 wpr482.0_20161222... (4 Replies)
Discussion started by: Siva SQL
4 Replies

3. UNIX for Dummies Questions & Answers

Loop with Perl (string search)

I am using a perl script to reverse and complement sequences if a string is found. The script works as expected as standalone but I would like to use it in my bash file. However, I am not getting my expected result. My test.txt file >Sample_72... (8 Replies)
Discussion started by: Xterra
8 Replies

4. Windows & DOS: Issues & Discussions

Batch file loop and increment value for condition

I am trying to have the below batch file do following two things: 1. only allow the values YES,yes,Y,y, or NO,no,N,n 2. increment the counter %var1 only if answer to question 2 is "y" and not able to get the syntax correct. If %var1%=1 then I am trying to display function :end. Thank you :).... (0 Replies)
Discussion started by: cmccabe
0 Replies

5. Shell Programming and Scripting

Recursive replacement of search string using sed

Dear Unix Forum Group Members, Please do let me know how I can replace the double pipe with single pipe recursively on single record. Sample Input Data: DN set|Call prefix||| Called number address nature 0||| *789|||||||ALL number types 0||| 00||||||||ALL number types 10||... (5 Replies)
Discussion started by: srinu.kadem
5 Replies

6. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

7. UNIX for Advanced & Expert Users

Full System Recursive Search for a String - Not Finishing

Using grep -r -H "foobar" / > result to give all files that contain the string "foobar" Half way , its waiting for some thing and does not end Not Sure whats happening. Any help is much appreciated Thank you (2 Replies)
Discussion started by: shorn
2 Replies

8. Shell Programming and Scripting

Recursive find / grep within a file / count of a string

Hi All, This is the first time I have posted to this forum so please bear with me. Thanks also advance for any help or guidance. For a project I need to do the following. 1. There are multiple files in multiple locations so I need to find them and the location. So I had planned to use... (9 Replies)
Discussion started by: Charlie6742
9 Replies

9. UNIX for Advanced & Expert Users

find file with date and recursive search for a text

Hey Guyz I have a requirement something like this.. a part of file name, date of modification of that file and a text is entered as input. like Date : 080206 (MMDDYY format.) filename : hotel_rates text : Jim now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)
Discussion started by: rosh0623
10 Replies

10. Shell Programming and Scripting

Recursive Search and replace only when found string

Hello all ( again ) I will like to search and replace string in text file ok I can loop throw the files like : foreach f ( ` find . -name "*."`) .. but here I like to examine the file if in contain the desired string and so do the sed -e 's/blah/foo/g' thingy on it or there is better way... (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question