hey guys,
i'm having some problems with my understanding of this whole regexp thing.
I'm just exploring here really by trying to do various match & filter & print stuff on the console.
I figured i want to get the IP of an interface. So my idea here was that first i filter to extract only the line with "inet" from ifconfig. Hence i type :
ifconfig rl0 | grep inet
this yields the two lines of ipv4 and ipv6 address configuration. Then i only take the 2nd field of each line since that's where the address really is hence i type :
ifconfig rl0 | grep inet | awk '{print $2}'
and i end up with both the ipv4 and ipv6 address so that's where it gets tricky for me. I thought that i'd put a last filter with a regexp to get the line that begins with a word made up of at least 1 and at most 3 digits:
ifconfig rl0 | grep inet | awk '{print $2}' | grep '^[0-9]{1,3}'
and it doesn't work, ie i end up with a void set. However if i remove the {1,3} quantifier, it does work
and i get the ipv4 address !
I don't understand this at all. Why does it work with only one occurence but if i say at least 1 and at most 3 it just fails
!!! Is there something flawed in my understanding of regexps ? Can someone provide some insights ?
PS:
i don't think it matters but just in case, i'm using tcsh