While loop break

We have a shell script that reads extdata.txt and extracts the information and merges the data into a table. There two while loops in the program. The inner loop is iterating too many times.
The requirement is we need to extract data only for 12 threads but it is running more number of time and extracting same data. Need to help to restrict the number of iterations.

Thanks
heartbeat-timestamp.sh
extdata.txt
basiranaAsked:
Who is Participating?
 
simon3270Commented:
The "exit 0" at the end is quite useful if you want to be sure that the script returns success - otherwise it will return the output status of the last command it ran, which may be non-zero even though the script was successful.

The odd one is the "exit 0" just before the "done" of the "while  (true)" loop - that basically means that the loop only ever executes once.  That would only make sense if there was a "continue" or "break" within the loop which altered the flow.

Also you don't need the parentheses wound the "true" - "while true" would work just fine.
0
 
tel2Commented:
Hi basirana,

I don't have time to study your script in detail, but...

Q1. What kind of shell script is this?  bash?

Q2. Have you tried running it in debug mode, like this:
    bash -x heartbeat-timestamp.sh
to try to see what's going on?
Or you could add some more echo statements at key points to show you what's happening.

BTW, no need to have "exit 0" at the very end of a shell script, as that happens by default.
0
 
arnoldCommented:
Is it perl (last), or a different shell Bash,Korn (break)
http://www.cyberciti.biz/faq/bash-while-loop/
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
basiranaAuthor Commented:
It is working now. It is a append problem
0
 
basiranaAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for basirana's comment #a38366644

for the following reason:

thanks
0
 
tel2Commented:
Hi basirana,

Could you show us exactly what the problem was, please?
And how did you discover it?

Thanks.
0
 
tel2Commented:
@simon3270,
Thanks for your correction to my "exit 0" comment.  Didn't realise that.  Good to know.

@basirana,
When deleting a question, instruction #2 that appears on the webpage is:
'Did you find your own solution? If you did, please click "Cancel", post your solution, and then close the question by clicking "Accept as Solution" on your own post.'
I don't think "It is working now. It is a append problem" gives enough detail for anyone to see what you have done to fix this.

I know I've basically asked this before, but I haven't yet seen a reply from you, so:
1. Could you show us exactly how you fixed the problem, please?  (I suggest you provide the new code, or at least the changes.)
2. And how did you discover the cause of the problem?

Thanks.
0
 
basiranaAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.