Re: GREP Help



Lew Pitcher <lpitcher@xxxxxxxxxxxx>:
On Jan 31, 8:20 pm, Garry Knight <garrykni...@xxxxxxx> wrote:
M wrote:
That gives me the lines that do not contain # but I want the lines that do
not begin with it.

Here's another way of doing it:
grep "^[^#]" /etc/my.conf

At 25 characters, both solutions are probably the shortest possible, but Lew
and Sinner's version is easier to type.

Yes, but your solution eliminates empty lines, and that might make the
results more readable.

Just another way to say the same thing, fwiw:

egrep -v '^#|^$' /etc/my.conf

29 chars, and it's a little more extensible. I use the same construct
for deselecting directories/files I don't want in my backups (one honking
long line, artifically broken for posting):

^/home/user/.netscape/cache| \
^/home/user/devl/kr/src/kernel-source-2.6.8| \
^/home/user/dwn| \
^/home/user/.opera/cache| \
lost\+found| \
^/home/user/.gnome2/epiphany/mozilla/epiphany| \
^/home/user/.galeon/mozilla/galeon/Cache| \
^/home/user/.mozilla/default/w2u0h33y.slt/Cache

Then:

find /somedir -depth -mount | egrep -v "`cat tarX_somedir`" | ...


--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://www.spots.ab.ca/~keeling Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
Spammers! http://www.spots.ab.ca/~keeling/emails.html
.



Relevant Pages

  • Re: why it is not giving any error?
    ... The issue is whether or not "characters use ascii conversion" is a valid ... Lew Pitcher ... IT Specialist, Enterprise Data Systems, ...
    (comp.lang.c)
  • Re: W and who commands username max 8 characters
    ... Lew Pitcher writes: ... > characters". ... in truth only the first 8 are significant. ... Sending unsolicited commercial e-mail to this account incurs a fee of $500 per message, and acknowledges the legality of this contract. ...
    (comp.unix.shell)
  • Re: how to print a short and long integer?
    ... Lew Pitcher a écrit: ... long l; s= -2; l= -3; printf("% _ %_",s, l); ... What characters should be filled out in the formatted string for output? ...
    (comp.lang.c)
  • Re: Text Editor
    ... Lew Pitcher wrote: ... > more characters to the screen. ... The system keeps the outstanding ... if you can pry it from my dead, cold, stiff fingers ...
    (alt.os.linux.suse)