UNIX Shell: cut a string

Posted on 2011-10-14
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?

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?
Question by:scpig
    1 Comment
    LVL 48

    Accepted Solution

    You could use a loop

    OraErrLine="ORA-12096: ORA-01653: ORA-04045"
    for err in $OraErrLine
      echo $err

    Open in new window


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    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 …
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    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…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now