Alex_Li
1
Hi all,
My file :test.txt just like this:
...........................
From: 333:123<sip:88888888888@bbbb.com
To: <sip:123456@aaaaa.com
.........................
I want a script to capture the string between sip:
& @
Expect output:
88888888888
123456
Please help!
Try something like:
sed 's/.*sip://;s/@.*//' test.txt
1 Like
In awk
$ awk 'gsub(".*sip:|@.*",x)' file
88888888888
123456
In Perl
$ perl -pe 's/.*sip:|@.*//g' file
88888888888
123456
Using Grep
$ grep -Po '(?<=sip:).*(?=@)' file
88888888888
123456
1 Like
Alex_Li
4
Great!
Many thanks for Don & Akshay.
Jotne
5
Some more awk
awk -F"sip:|@" '{print $2}' file
gnu awk
awk '{print gensub(/.*sip:(.*)@.*/,"\\1","g")}' file
1 Like