1748285 Members
4057 Online
108761 Solutions
New Discussion юеВ

Re: sed issue?

 
SOLVED
Go to solution
Jack_27
Advisor

sed issue?

Dear all,

Could you please tell me what's the meaning of:
grep -E '^exception:' $LOG | sed 's=[^.]*.\([0-9]*\).*=\1='

I can't find any clue of "s=..." in the manual of sed.

Thanks
Jack
3 REPLIES 3
Ermin Borovac
Honored Contributor
Solution

Re: sed issue?

s/regular expression/replacement/flags

Any character can be used instead of /.

In your case they used equal sign (=).

This sed command will match some text not containing dot character (.), followed by dot (.), followed by zero of more numbers, followed by zero of more characters. Numbers matched after the dot will be returned (\1).

hello world blah.123 hello world

and will return 123.
Santosh Nair_1
Honored Contributor

Re: sed issue?

The '=' character is being used as a delimiter in sed, i.e. instead of the default '/' character.

As for the sed command, it looks like its looking for a number of non-dot characters, followed by a dot (.), followed by a number, followed by other characters. In its place it was put just the number, i.e. abcdef.12345ghijk will become 12345.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
Jack_27
Advisor

Re: sed issue?

It's resolved.

Thank you both experts!
Jack