Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sed substring from incoming packet

Tags:

regex

linux

sed

String I want to sed i get from incoming sniffered packet... I want to get substring from string, f.e.

INVITE sip:[email protected]:5060 SIP/2.0

Using sed I would like to extract substring.
Substring is between sip: and @ ... So for my example, I need to get

18455845013
like image 921
timonvlad Avatar asked Jan 31 '26 04:01

timonvlad


1 Answers

Input file

$ cat foo.txt
INVITE sip:[email protected]:5060 SIP/2.0

Result

$ sed 'y/:@/\r\n/;P;d' foo.txt
18455845013
  • change : to \r
  • change @ to \n
  • print up to first newline
  • delete pattern space
like image 152
Zombo Avatar answered Feb 01 '26 21:02

Zombo