8.1178, Sum: Grepping

The LINGUIST List linguist at linguistlist.org
Fri Aug 15 00:18:34 UTC 1997


LINGUIST List:  Vol-8-1178. Thu Aug 14 1997. ISSN: 1068-4875.

Subject: 8.1178, Sum: Grepping

Moderators: Anthony Rodrigues Aristar: Texas A&M U. <aristar at linguistlist.org>
            Helen Dry: Eastern Michigan U. <hdry at linguistlist.org>
            T. Daniel Seely: Eastern Michigan U. <seely at linguistlist.org>

Review Editor:     Andrew Carnie <carnie at linguistlist.org>

Associate Editors: Ljuba Veselinova <ljuba at linguistlist.org>
                   Ann Dizdar <ann at linguistlist.org>
Assistant Editor:  Martin Jacobsen <marty at linguistlist.org>

Software development: John H. Remmers <remmers at emunix.emich.edu>
                      Zhiping Zheng <zzheng at online.emich.edu>

Home Page:  http://linguistlist.org/


Editor for this issue: Martin Jacobsen <marty at linguistlist.org>

=================================Directory=================================

1)
Date:  Thu, 14 Aug 1997 12:07:09 +0530 (IST)
From:  Dr R Doctor <doctor at cdac.ernet.in>
Subject:  GREPPING SUMMARY

-------------------------------- Message 1 -------------------------------

Date:  Thu, 14 Aug 1997 12:07:09 +0530 (IST)
From:  Dr R Doctor <doctor at cdac.ernet.in>
Subject:  GREPPING SUMMARY

Thanks to all who responded to my request for grepping under a DOS
environment with the following syntax:

< grep -r <FN1> <FN2> FN3 >

< where FN1 is the file with the set of strings to be grepped	>

< FN2 is the data-base >

< FN3 is the output.  >

With the suggestions and help that I have got, I have literally
"grepped" all about GREP.  Thanks a lot I got a whole lot of answers
which I am summarising below:

1. The first was to use PERL script to write my own GREP: For both
Unix and dos, perl is a language that will easily allow to create a
small program that will do what you ask. More information about perl,
including free downloads for many environments, can be gotten from the
perl language home page, http://www.perl.com/perl/index.html.

2. The second suggestion was similar in nature: use AWK and LEX tools
for the job.

3.Under UNIX environment three types of GREP were proposed:
a. egrep

	egrep -f fn1 fn2 > fn3

where fn1 is a file containing the search patterns (one per line). If
you only want to search for literal strings (no special characters)
then you can use fgrep instead of egrep. Do 'man grep' for more
details,

b. fgrep

	fgrep -f patt-file-name < database-to-search > results-file
will work, assuming patt-file-name is a file of _strings_ (regular
expressions containing metacharacters are not allowed by fgrep.)  Say
	man fgrep
to get the details.
	One hitch however it will only match strings, not regular
expressions.

c.sgrep
  The sgrep utility (not standard UNIX) permits complex (and nested)
  patterns to be searched for.


4. Under DOS
The gnu tools are now available under DOS; gnu has only one
grep and lets you do this (according to the manual) with
	grep  -f F1 F2 >F3
This works and I have used it with success. Thanks to Andreas Mengel

Incidentally egrep,sgrep and fgrep versions for DOS exist and can be
found at:

	ftp.rediris.es/mirror/simtelnet/gnu/gnuish/grep15.zip
	Thanks to Susana Sotelo Docio

5. Another suggestion was to use sed
   sed -n -f <file> permits many patterns to be searched for (with
   some problems when multiple matches occur on a line.

6. Another solution under DOS was to grep for a large number of
strings at once in a `regular expression'.

   A second alternative was to batch-file the operation, which I am
using at present as a solution, but wanted something more functional.

7. A commercial solution was also proposed: MKS (Mortice-Kern) in
Canada makes a commercial set of Unix apps and commands for use in DOS
and Windows environments, including ksh, awk, grep, gres.  Their grep
syntax is:
	grep -f pattfile file > output


______________________________________________________________________
Many Thanks to:

Martin Wynne <eiamjw at comp.lancs.ac.uk>
Will Dowling <willd at spectranet.ca>
Kevin Bretonnel Cohen <kevin at cmhcsys.com>
Mark Liberman <myl at unagi.cis.upenn.edu>
John E. Koontz koontz at boulder.nist.gov
Peter Hamer <P.G.Hamer at nortel.co.uk>
Stuart Luppescu <s-luppescu at uchicago.edu>
Stephen P Spackman <stephen at softguard.com>
D.Lee <d.lee at lancaster.ac.uk>
Chris Culy <cculy at blue.weeg.uiowa.edu>
David Palmer <palmer at linus.mitre.org>
Shravan Vasishth <vasishth at ling.ohio-state.edu>
Susana Sotelo Doc'io" <fesdocio at usc.es>
Andreas Mengel <mengel at babylon.kgw.tu-berlin.de>

for their prompt and helpful replies to my query.

---------------------------------------------------------------------------
LINGUIST List: Vol-8-1178



More information about the LINGUIST mailing list