correct • elegant • free

△ △

◅ remote login via shell script

timer script ▻

A bit of a grep stumper

In article <>,
Mediocrates  <Mediocrates@don'tbother.spammingme> wrote:
>Here's what I'm trying to do: grep for either a or b. According to info
>and man I need to use the infix operater '|' .

Such things are usually discussed on followups there.

>                                               However, doing a "grep
>a|b" obviously won't work due to linux interpreting it as a pipe

It's your shell that interprets it as the pipeline operator; you just
need to put quote marks around it.

>          and "\|" means to look for a "|". Does anyone know how to get
>it to work?

Traditionally, only egrep supports alternation.

    egrep 'a|b' /etc/group

With the GNU grep utilities, you have a bewildering choice.  You can
use `egrep', as above; you can use `grep -E', which makes `grep' behave
almost like `egrep'; or you can backwhack the alternation operator.

    grep -E 'a|b' /etc/group
    grep 'a\|b' /etc/group

Tim Goodwin   | "People think [ W. Gibson is ] hi-tech because his prose
Leicester, UK | is as pleasant to read as a C++ program." -- JT

Original headers:

From: (Tim Goodwin)
Newsgroups: gnu.misc.discuss,
Subject: Re: A bit of a grep stumper
Date: 3 Nov 1999 10:20:10 -0000
Organization: University of Leicester, UK
Message-ID: <7vp29g$8qo$>
References: <>

△ △

◅ remote login via shell script

timer script ▻