[ILUG] regular expression question
mark at skynet.ie
Tue Nov 13 16:53:38 GMT 2001
On Tue, 13 Nov 2001, Padraig Brady wrote:
> [padraig at pixelbeat findul]$ cat input.txt
> OK I want to only show files in /lib/ or /usr/lib/
> so I'm trying to exclude lines that have a / after
> these 2 strings.
> So try 1: Match 1 or more characters not /
> [padraig at pixelbeat findul]$ cat input.txt |
> grep "\(^/usr/lib/[^/]+$\|^/lib/\)"
> This didn't match the last entry, why?
Strange indeed. Interestingly
grep "\(^/usr/lib/[^/][^/]*$\|^/lib/\)" < input.txt
works. So it may be a bug ?
Out of curiousity - how come you didn't try something like
grep "^/\(usr/lib$\|^lib\)/[^/]+$" < input.txt
More information about the ILUG