Home » Infrastructure » Unix » Find a String on a variable
Find a String on a variable [message #270322] Wed, 26 September 2007 09:32 Go to next message
reksab_16
Messages: 8
Registered: September 2007
Junior Member
Gurus,

Please help me on this regard.

I have a string variable x in the shell Script.

I wanna find out whether this string contains text 'ORA-'. If it contains, I have to write error message to the error File and abort the execution of the shell script

Else
Continue the process.

Can you please help me with a code snippet?

Thanks.
Re: Find a String on a variable [message #270324 is a reply to message #270322] Wed, 26 September 2007 09:42 Go to previous messageGo to next message
BlackSwan
Messages: 25037
Registered: January 2009
Location: SoCal
Senior Member
IMO, you are using the wrong tool for this job.
When the only tool you have is a hammer, you treat all problems as nails.
A hammer is not the right tool to make 2 pieces of lumber out of 1 baord.

IMO, a MUCH better choice to interact between OS & Oracle is PERL
Re: Find a String on a variable [message #270340 is a reply to message #270322] Wed, 26 September 2007 10:25 Go to previous messageGo to next message
Michel Cadot
Messages: 64110
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Something like:
rc=`echo $x | grep 'ORA-' | wc -l`
if [ $rc -ne 0 ]
then
  echo 'ERROR'
  exit
fi

But I agree with Ana, if you are starting to make complex things it is better to use Perl as scripting language.

Regards
Michel
Re: Find a String on a variable [message #270392 is a reply to message #270324] Wed, 26 September 2007 14:24 Go to previous message
reksab_16
Messages: 8
Registered: September 2007
Junior Member
Thanks a lot.

This was very much useful.

I appreciate you help. I am asked only to use Shell Scripting for my Programming. That's y I am coding in that.

Also I need to master in Unix. Can you please suggest me some materials which contains practical examples to start with?

Thanks a Lot,

Bhaskar Natarajan.

Previous Topic: AIX and CIO (concurrent I/O)
Next Topic: Logic Validation
Goto Forum:
  


Current Time: Mon Dec 05 10:52:12 CST 2016

Total time taken to generate the page: 0.08304 seconds