The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-25-2008
mam mam is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 6
extracting data and store in database

Hello all,
I have this text file data. The data are separated by comma in three column and space or line feed to start a new row

Code:
anderson helberg, Jane, brother
Sister ,mother,grandpa
bombay,new york, china

I would like store them in the following format.

Code:
field1                           field2                              field3
anderson helberg              Jane                               brother
bombay                         new york                         china

my problem is how to implemet the script with both line feed or single space or multiple space and comma separator to separate the rows and stores the data as shown above.
by using cut and delimiter.

Code:
anderson helberg=`echo "$text" | cut -f 1 -d','`

please anyone with help appreciated