From owner-freebsd-questions Wed May 22 08:40:11 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id IAA04556 for questions-outgoing; Wed, 22 May 1996 08:40:11 -0700 (PDT) Received: from hellcat.umd.edu (hellcat.umd.edu [129.2.70.125]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id IAA04520 for ; Wed, 22 May 1996 08:40:06 -0700 (PDT) Received: from cappuccino.eng.umd.edu (cappuccino.eng.umd.edu [129.2.98.14]) by hellcat.umd.edu (8.7.5/8.7.3) with ESMTP id LAA01091; Wed, 22 May 1996 11:40:00 -0400 (EDT) Received: (chuckr@localhost) by cappuccino.eng.umd.edu (8.7.5/8.6.4) id LAA02065; Wed, 22 May 1996 11:39:54 -0400 (EDT) Date: Wed, 22 May 1996 11:39:54 -0400 (EDT) From: Chuck Robey X-Sender: chuckr@cappuccino.eng.umd.edu To: "Gregory, Scott D. SRA SAF/AADO" cc: questions Subject: Re: Help With Scripts In-Reply-To: <31A323B6@pubspo.hq.af.mil> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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! ----------------------------+-----------------------------------------------