Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 1996 11:39:54 -0400 (EDT)
From:      Chuck Robey <chuckr@glue.umd.edu>
To:        "Gregory, Scott D. SRA SAF/AADO" <sgregory@PUBSPO.hq.af.mil>
Cc:        questions <questions@freebsd.org>
Subject:   Re: Help With Scripts
Message-ID:  <Pine.SUN.3.91.960522113453.1360F-100000@cappuccino.eng.umd.edu>
In-Reply-To: <31A323B6@pubspo.hq.af.mil>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 22 May 1996, Gregory, Scott D. SRA SAF/AADO wrote:

> 
> Hi,
> 
> I'm trying to write a script to create HTML pages from a text file (output 
> from a database).  I'm new to FreeBSD (2.1) and UNIX and I can't find the 
> appropriate books at the library.
> 
> My text file is delimited by '@' and has 7 fields (see below).  I would like 
> to convert this into a HTML table.  An example of how I would like my output 
> is below.  The example shows what fields I would like and where they should 
> be placed.  I would like to separate the pages by the 100 (00-99 (saved to 
> filename af0000-0099.html, af0100-0199.html, etc.) (field 1--AF000, AF001, 
> AF002, etc.), however, the directory location of the file is by the 1000 
> (which is why I need to extract characters 1,2 and 4 from the 1st field.
> 
> I'm not currently subscribed to questions, so please email me directly at 
> sgregory@pubspo.hq.af.mil or sgregory@ameritel.net.  Thanks in advance for 
> your assistance.

The appropriate tool would either be perl or awk.  Reasonably easy to 
do.  I don't know perl (others may jump in here on that) but in awk, 
you'd use the FS (field separator variable), set it to "@", then just use 
a BEGIN clause (to set up FS, and print the front matter), a default 
clause (to print each record, in any format that suits you), then an END 
clause to print the end matter.

O'Reilly has a good book on Awk, "sed & awk", but Dale Dougherty.  I'd 
recommend it.  Awk's a very good tool to learn to use.

----------------------------+-----------------------------------------------
Chuck Robey                 | Interests include any kind of voice or data 
chuckr@eng.umd.edu          | communications topic, C programming, and Unix.
9120 Edmonston Ct #302      |
Greenbelt, MD 20770         | I run Journey2 and n3lxx, both FreeBSD
(301) 220-2114              | version 2.2 current -- and great FUN!
----------------------------+-----------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.960522113453.1360F-100000>