Under tcsh the grep dies with an error unless I change the "s to 's. This is
because the shell sees $\ as a variable. Maybe in your shell $\ is not an
unknown variable and so grep executes but does the wrong thing. Try replacing
grep with echo and see if the regexp is printed out correctly.
Also, one thing that seems wrong is the fact that you only check the [^/]+
after /lib/ and not /usr/lib/.
As a Perl bigot, I think you should use egrep or grep -E to get rid of those
Anyway, this seems to do what you require
cat input.txt | grep -E '^(/usr/lib/|^/lib/)[^/]+$'
On Tuesday 13 November 2001 16:15, 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?
>> The following works but is not just robust?
> [padraig at pixelbeat findul]$ cat input.txt |
> grep "\(^/usr/lib/[^/]*$\|^/lib/\)"
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!