2 of 2 edited tags

grep searching groups

I'm trying to learn to use grep groups, like sed \1\2\3, but have a problem. For example I filtering /etc/services file to separate all ports. What I do:

~$ grep -E '[0-9]{1,5}/(tcp|udp)' /etc/services

and now I get 'port/protocol'. Next, I try separate it with groups:

~$ grep -E '\([0-9]{1,5}\)/(tcp|udp)' /etc/services

and haven't any effect. Well, trying non extended grep:

~$ grep '\([0-9]*\)/[tcp\|udp]\1' /etc/services

but results not right (/t or /u). So, how to use groups?