Operating System - HP-UX
1833113 Members
3565 Online
110051 Solutions
New Discussion

Re: Echo with grep command and concatenation

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

Echo with grep command and concatenation

Hi Guys


In my script this.

echo $VX "Errors: "
echo "$spout" | grep -i "ORA-"

The result is (Example)
TEST1DB Failed
ORA-01109: database not open


How to have this on the same line and including "(" ")":

TEST1DB Failed (ORA-01109: database not open)

Any idea ?
Bests Regards
Den

5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: Echo with grep command and concatenation

To get the results all on the same line:

echo $VX "Errors: \c"
echo $spout" | grep -i "ORA-"

As for the parentheses, if they are in the string you are grepping for, they should be included.
James R. Ferguson
Acclaimed Contributor
Solution

Re: Echo with grep command and concatenation

Hi Den:

Given:

# VX="TEST1DB Failed"
# spout="ORA-01109: database not open"

Then:

# printf "%s (%s)\n" "$VX" "$spout"
TEST1DB Failed (ORA-01109: database not open)

Regards!

...JRF...
Leo The Cat
Regular Advisor

Re: Echo with grep command and concatenation

OK with answer
James R. Ferguson
Acclaimed Contributor

Re: Echo with grep command and concatenation

Hi:

> OK with answer

Good, but please don't forget to assign points when you are happy with the responses you have received. To reopen your thread to assign points:

http://forums.itrc.hp.com/service/forums/helptips.do?#41

http://forums.itrc.hp.com/service/forums/helptips.do?#28

...JRF...

Leo The Cat
Regular Advisor

Re: Echo with grep command and concatenation

Sorry James,

IN the fire of the action sometime I missed to go back for points immediately. because tests, because something but I always attribute on last posts

Thanks for your help, it's always very appreciate for me.

Have a good Xmas
Bests Regards
Den