TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
Subject:Re: Line Numbers in ASCII File From:Sandy Harris <sandy -at- storm -dot- ca> To:"TECHWR-L" <techwr-l -at- lists -dot- raycomm -dot- com> Date:Thu, 07 Feb 2002 11:46:13 -0500
Steve Goldberg wrote:
>
> We have a huge ASCII text file against which we would like to do
> searches to find matching strings in the text. Once we match a
> particular text string we would like to be able to determine on what
> line number or page number that string is located.
> Does anyone know of a way to do this? In Word, of course, it's simple,
> but that formatting is lost when the file is saved as plain text.
On Unix, or with Unix tools installed on a Win box:
that's just grep -n. This has been a standard tool since at least the
late 70s.
It also gives the ability to match more complex patterns. For example.
grep -n '1\-8[08][08]\-[0-9]+'
is my (first guess, without looking at the manual, and untested, so quite
likely wrong) attempt to get all lines with North American toll-free phone
numbers. It matches any string with these pieces, in order:
"1-8"
"0" or "8"
"0" or "8"
"-"
at least one digit
With some practice and a bit of mucking about, you can do quite a
lot with this "regular expression" search facility.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Collect Royalties, Not Rejection Letters! Tell us your rejection story when you
submit your manuscript to iUniverse Nov. 6 -Dec. 15 and get five free copies of
your book. What are you waiting for? http://www.iuniverse.com/media/techwr
---
You are currently subscribed to techwr-l as: archive -at- raycomm -dot- com
To unsubscribe send a blank email to leave-techwr-l-obscured -at- lists -dot- raycomm -dot- com
Send administrative questions to ejray -at- raycomm -dot- com -dot- Visit http://www.raycomm.com/techwhirl/ for more resources and info.