awk / sed

I have many messages such as the test message below:

00:00000:00021:2002/05/13 13:57:00.51 ERROR:- Test error, my test error!!!

I am writing a script in which I need to get everything from the word "ERROR:-" onwards.

I normally use awk for these things, but I am not an expert at it so i am at a loss here. Is there a way to use awk to get everything from $6 to the end of the line without doing awk '{print $6, $7, $8 .....}' and so forth as the end of the line will vary.

Or is there a way in sed that does this instead as the only way I have found on this forum is below and I would like something a bit neater and more accurate:
sed 's/^.........................................................//

Thank you.

You can try this. I know that this is down and dirty...

awk -F "ERROR:" '{ print "ERROR:", $2 }' .

You can use the uppercase error: and then insert it back with the print option.

Hope this helps...
:smiley:

How about:
sed 's/.*ERROR/ERROR/'

Perderabo,

Cool response!! to replace the whole first part with sed... to get rid of every thing before "ERROR:"

AWESOME!!

:stuck_out_tongue: :wink:

Thanks for the help. That will work for some of our errors. Unfortunately not all of our errors have "ERROR:-", only the ones generated by our team's maintenance scripts. Some errors are generated by our dataserver and can come out in many different formats.

Is there any way to ask for everything before an alpha to be removed? As no matter how the error comes out there is only the time stamp proceeding the error message.

eg: 00:00000:00002:2002/04/30 21:52:32.27 error

Thanks again :slight_smile:

sed 's/^[^a-zA-Z]*//'

Thanks for that. I tried using [a-z] myself but I couldn't figure out how the [a-z] was going to work as it errored with the combo's i tried. At least i was on the right track.

Thanks again.