Help!!!!!!

Help!!!!!!

Post by Darren Shilso » Tue, 12 Aug 1997 04:00:00



Hi,

I'd appreciate someones help on this.

I'm pretty new to Unix and am still learning bits and bobs here and
there.

The Problem.

I have a text file in Unix holding information.

Each field is separated by a semicolon

i.e

Surname;Forename;Department;Extension;Title;FaxNo;DirectNo

I want to create a excel file which uses these fields to create a proper
listing by Department. I can do the macro, but I need a way of
converting the file in Unix and outputting it, sorted by the Department
field.

I saw a way of using Grep and will ideally like to use this to search
for a particular department and record all the details in a txt file and
so on until all the departments are accounted for. The txt file would be
updated, not replaced each time

This file can then be use as a  basis for my excel macro

Does anyone know a quick and simple way to do this??

Thanks

Darren

 
 
 

Help!!!!!!

Post by Ravi C. Kuma » Wed, 13 Aug 1997 04:00:00



> Hi,

> I'd appreciate someones help on this.

> I'm pretty new to Unix and am still learning bits and bobs here and
> there.

> The Problem.

> I have a text file in Unix holding information.

> Each field is separated by a semicolon

> i.e

> Surname;Forename;Department;Extension;Title;FaxNo;DirectNo

> I want to create a excel file which uses these fields to create a proper
> listing by Department. I can do the macro, but I need a way of
> converting the file in Unix and outputting it, sorted by the Department
> field.

All you have to do is

sort -t ";" -k 3,3 filename and redirect the output to a different file.

The doze nl char is (\015), so before uploading it into doze,
do

tr '\012' '\015' on the file.

Remember that both sort and tr require separate files to operate upon,
so move the new file to old file afterwards.

Quote:> Darren

PS:  Questions of this nature are usually addressed in comp.unix.shell
or comp.unix.questions.  

--
Opinions are my own

 
 
 

Help!!!!!!

Post by Ronald Fische » Wed, 13 Aug 1997 04:00:00


>>>>> On Mon, 11 Aug 1997 13:42:12 +0100


DS> I have a text file in Unix holding information.
DS> Each field is separated by a semicolon
DS> i.e
DS> Surname;Forename;Department;Extension;Title;FaxNo;DirectNo
DS>
DS> I want to create a excel file which uses these fields to create a proper
DS> listing by Department. I can do the macro, but I need a way of
DS> converting the file in Unix and outputting it, sorted by the Department
DS> field.
DS>
DS> I saw a way of using Grep and will ideally like to use this to search
DS> for a particular department and record all the details in a txt file and
DS> so on until all the departments are accounted for. The txt file would be
DS> updated, not replaced each time

Not sure I understand what you are asking for. You can sort your file
by department with the command
    sort -t';' +2 <YOURFILE >SORTEDFILE
You can use grep to look for a department by
    grep "^[^;]*;[^;]*;YOURDEPARTMENT;" <YOURFILE
be it sorted or not.
--

http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]

 
 
 

Help!!!!!!

Post by Markku Laukkane » Wed, 13 Aug 1997 04:00:00



> Each field is separated by a semicolon

> i.e

> Surname;Forename;Department;Extension;Title;FaxNo;DirectNo

....

Quote:> Does anyone know a quick and simple way to do this??

> Thanks

> Darren

     Hmm, what version of sort you are using in your unix box ?

Try

sort  <input_file -t \; -k 3 >output_file

    PKY