Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!munnari.oz.au!murtoa.cs.mu.oz.au!ditmela!yarra!melba.bby.oz.au!leo!gnb From: gnb@bby.oz.au (Gregory N. Bond) Newsgroups: comp.unix.wizards Subject: I thought I understood Regexps... (Bug in SunOs grep?) Message-ID: <1990Mar2.060230.7757@melba.bby.oz.au> Date: 2 Mar 90 06:02:30 GMT Sender: gnb@melba.bby.oz.au (Gregory N. Bond) Organization: Burdett, Buckeridge and Young Ltd. Lines: 45 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@melba.bby.oz.au non-MX: gnb%melba.bby.oz@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@melba.bby.oz.au non-MX: gnb%melba.bby.oz@uunet.uu.net Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb