LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-22-2008, 02:12 AM   #1
hchoonbeng
LQ Newbie
 
Registered: Sep 2008
Posts: 15

Rep: Reputation: 0
how to check for error in a particular file


Hi I try

for i in 1 to 100
do
#execute prog
content=$(</tmp/htx.flpb_sqrt0) #output file after prog executed
echo $content
done

Output file [default CON]: Successful Tests: 0 Numerical Errors: 0

I need to check if the numerical error is not 0 in the file. how to go abt using script and saving the output to a file?


thanks
 
Old 10-22-2008, 03:23 PM   #2
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 46
Moin,

you can use sed to extract the interesting part of the file (I assume it has only this one line?):
Code:
num_errors=$(sed -r 's/.*Numerical Errors: ([0-9]+).*/\1/' /tmp/htx.flpb_sqrt0)
To check the value:
Code:
if test $num_errors -ne 0; then
  # error(s) occured, do something interesting
else
  # no error: do something else
fi
To write the error number to a file:
Code:
echo $num_error >output_file
Jan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File System Check error sharathkumaru Linux - Newbie 5 07-23-2008 02:01 AM
file system check error pzanis Linux - General 2 07-05-2006 08:12 AM
error During the file system check Gortex Linux - Newbie 5 06-18-2006 12:03 AM
error during file system check laurentwahl Linux - General 1 05-21-2005 08:33 PM
Redhat 7.1-error during file sys. check-what do I do? wuffneezell Linux - Newbie 1 04-11-2004 07:13 PM


All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration