?
Solved

UNIX Shell: cut a string

Posted on 2011-10-14
1
Medium Priority
?
660 Views
Last Modified: 2012-05-12
I have a varaible that is a string.  How do I cut each of "ORA-xxxxx" as a single string?  My problem is the variable may contains more than 1 or 2 or 3 ORA error codes.  How do I deal with it?

Example:
OraErrLine=ORA-12096: ORA-01653:

And it could be:
OraErrLine=ORA-12096: ORA-01653: ORA-04045

and maybe more ORA- in the variable $OraErrLine

How do I cut each "ORA-xxxxx:" as a single string while we don't know how many ORA- could happen?
0
Comment
Question by:scpig
1 Comment
 
LVL 48

Accepted Solution

by:
Tintin earned 1000 total points
ID: 36971033
You could use a loop

OraErrLine="ORA-12096: ORA-01653: ORA-04045"

IFS=":"
for err in $OraErrLine
do
  echo $err
done

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question