Building cross reference -- how?
Walter Dnes
waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Sun Oct 13 08:22:44 UTC 2013
On Sun, Oct 13, 2013 at 02:14:04AM -0400, William Park wrote
> Hi all,
>
> I want to build cross reference on certain lines in files. I can
> extract those lines into a file, say in format
> filename,...line...
>
> Now, how do I build cross reference?
>
> For example, if I have
> file1, one two three red
> file2, four five
> file3, red blue yellow
> file4, blue one
> Then, cross reference for "red" should give me first line (file1) and
> 3rd line (file3). And, cross reference for "red one" should give me
> only the first line (file1). I guess I can do
> fgrep -e red
> fgrep -e red | fgrep -e one
>
> Is there a program, similar to "updatedb" and "slocate"?
It sounds almost like you want to create a concordance. Various word
processors (e.g. MS Word) can do it. A free (as in beer, only; no
source) linux program is available from...
http://www.antlab.sci.waseda.ac.jp/antconc_index.html
It could probably be done as a 2-pass bash script. See...
http://stackoverflow.com/questions/9056829/concordance-of-text for a
start. Pass 1 would be creating the list (don't need the count). Pass
2 would use the output from Pass 1 as a pattern file. Something like...
grep -Hno -f <output_file_from_Pass_1> list_of_input_files
--
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
I don't run "desktop environments"; I run useful applications
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list