[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: matching exact lines in files

From: Jim Showalter
Subject: Re: matching exact lines in files
Date: Wed, 04 Oct 2006 21:18:33 GMT
User-agent: KNode/0.10.1

Alan Curry wrote:

> In article <ftOUg.4846$>,
> I can search for newlines just fine with vim, using \n.

Well I'll be... that works - thanks!

> If I can guess your intent (rather than just giving you exactly what you
> asked for), these are probably what you really want:
> # Find all lines that exactly match [Event "ICC"] and print them, together
> # with 1 preceding line.
> grep -B 1 -Fx '[Event "ICC"]' file
> # Same thing, then get rid of the [Event "ICC"] lines and the separators
> # leaving only the lines that preceded the [Event "ICC"] lines
> grep -B 1 -Fx '[Event "ICC"]' file |
>   grep -Fxv -e '[Event "ICC"]' -e '--'
> # Building on the previous example, group and count the occurrences of
> # each result
> grep -B 1 -Fx '[Event "ICC"]' file |
>   grep -Fxv -e '[Event "ICC"]' -e '--' | sort | uniq -c

Well, you didn't quite guess my intent.  I just want to find cases
where there is no intervening blank line and insert one.

If we find this:

[Event "ICC"]

We change it to this:


[Event "ICC"]

Thanks much,
_/  Everything should be made as simple as possible, but not simpler.
_/                           -- Albert Einstein

reply via email to

[Prev in Thread] Current Thread [Next in Thread]