[102356] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: parsing text files

daemon@ATHENA.MIT.EDU (Vidiot)
Wed Dec 2 15:53:06 1998

From: Vidiot <brown@ftms.COM>
To: redhat-list@redhat.com
Date: Wed, 2 Dec 1998 14:51:46 -0600 (CST)
In-Reply-To: <NCBBKAHLNJCALPEJDMAEGEPPCDAA.elazor@hcs.state.or.us> from "Ed Lazor" at Dec 2, 98 12:33:05 pm
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

>Is there a unix command that I can use to parse a column of text from a
>file?
>For example, a command that would allow me to parse the column titled
>address
>from a file with the following information and output it to another file?
>
>Name		Address	Town
>bob		123 A st.	Somewhere
>steve		123 B st.	Somewhere
>joe		123 C st.	Somewhere
>gloria	123 D st.	Somewhere

I'm not sure what a list of street names would do for you without the city
the street is in, but, no, there isn't a simple program with a simple set
of options that will extract that info.  At least, not that I know of.

But, programs like Perl and awk have the ability to parse said text files
and extract said information.  I do that now with a satellite wildfeed list,
using awk and sed.  As long as there are two or more spaces separating
columns, or if there is a separator character, like ;, then awk can be used
to extract the fields/columns.  If the columns line up, then awk can easily
extract the address column, and you could probably actually do it on a
command line.  Though I suggest putting it inside a shell script, so that
you can modify it and have the syntax available the next time you want to
do it (it is easier to remember a simple script name than to remember what
you entered on a command line, especially for awk :-)

I could probably put together an awk script for you in no time, if I knew
the details of your file.

MB
-- 
System Administrator - Finnigan FT/MS - Madison WI. URL:http://www.ftms.com/
e-mail: brown@ftms.com   phone: (608) 273-8262 ext: 612  fax: (608) 273-8719
        [Where do you think Microsoft would be today if they waited]
        [until their software worked?     (Hyperion Bay - 10/12/98)]
Visit - URL:http://www.vidiot.com/  (Your link to Star Trek and UPN)


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post