help-gnu-utils
[Top][All Lists]
Advanced

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

matching exact lines in files


From: Jim Showalter
Subject: matching exact lines in files
Date: Wed, 04 Oct 2006 13:14:51 GMT
User-agent: KNode/0.10.1

I hope questions about 'diff' and 'vim' are on topic in this
newsgroup.  If not, please suggest a more appropriate group.

Is there a way, using diff, to display only the lines in text file
'a', let's call it a.txt, that match lines in text file 'b', b.txt?

Specifically, I want is to find all lines in a.txt that match any of
the following three groups of lines in b.txt:

1-0
[Event "ICC"]

0-1
[Event "ICC"]

1/2-1/2
[Event "ICC"]


Occurrences in a.txt, such as:

1-0

[Event "ICC"]


should not match because there is an intervening blank line.

I have tried experimenting with the "--line-format" switch, such as
"--old-line-format=%=" ("%=" should match common lines).  But while I
think I'm on the right track, I get screens of wall-to-wall "%=%=%=".

Also, if anyone knows how I can accomplish this easily with vim, that
would even be better.  But I have never been able to figure out how
to include end-of-lines or blank-lines in vim searches.

Or maybe I have to use some other tools?

Anybody?
-- 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/  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]