I thought I understood Regexps... (Bug in SunOs grep?)

Gregory N. Bond gnb at bby.oz.au
Fri Mar 2 17:02:30 AEST 1990


I have a large du listing of the form

100	./a/b/c
121	./a/b
200	./a


I am trying to summarise it by only displaying the top two directory
levels, i.e. ./a and ./a/b but not ./a/b/c etc.

So I tried a grep: 
	grep < usage '\.\(/[^/]*\)\{1,2\}$'

On SunOs 4.0.3, on 3/80 and Solbourne 5/601, and /usr/5bin/grep on
Sun3/260 and SunOs 3.5, this don't work.

If I have \{1\} I get top level (./a) only (as I expect), but \{3\}
ALSO give me top level only.  In fact, ANY digit is equivalent to \{1\}.
And combinations of digits \{m,n\} gives different results, sometimes
acting as \{1\} and sometimes passing all lines.

And the similar regexp

	'^[0-9]*[ 	].\(/[^/]*\)\{1,2\}$'
		 ^^ This is a space and a tab

will coredump grep on SunOs on both the 3/80 and the Solbourne.  The
/usr/5bin/grep under SunOs 3.5 just ignores the \{..\} and prints all
lines. 

Is this a bug in grep or is my regex wrong?

(I eventually solved it using sed, like: 
	sed -n -e '\=\./[^/]*$=p' -e '\=\./[^/]*/[^/]*$=p' < usage
)

Greg.
--
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb at melba.bby.oz.au    non-MX: gnb%melba.bby.oz at uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb
-- 
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb at melba.bby.oz.au    non-MX: gnb%melba.bby.oz at uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb



More information about the Comp.unix.wizards mailing list