[sf-lug] shell, man(1) [was: path name expansion]

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sun Aug 21 00:22:35 PDT 2016


> From: "Alex Kleider" <akleider at sonic.net>
> Subject: Re: [sf-lug] shell, man(1) [was: path name expansion]
> Date: Sat, 20 Aug 2016 17:19:05 -0700

> On 2016-08-20 09:04, Daniel Gimpelevich wrote:
>> On Sat, 2016-08-20 at 08:59 -0700, Alex Kleider wrote:
>>> I don't understand the grep -v '^XT' part.
>>
>> It means lines that do not start with XT.
>
> man grep
> ....
>        -v, --invert-match
>               Invert the sense of matching, to select non-matching  
> lines.  (-v
>               is specified by POSIX.)
>
> Now I get the syntax, but why?

Because sometimes that's exactly what you want to do.
Which do you think is more clear for showing what SHELL is set to
in the environment?

$ printenv | grep SHELL
SHELL=/bin/bash
XTERM_SHELL=/bin/bash
$ printenv | grep SHELL | grep -v '^XT'
SHELL=/bin/bash
$

Of course we also could've just done:
$ printenv | grep '^SHELL='
SHELL=/bin/bash
$

Anyway, sometimes what you want is what *doesn't* match.





More information about the sf-lug mailing list