If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Replace spaces in log file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-06, 09:24
mattlucas mattlucas is offline
Registered User
 
Join Date: Aug 2006
Posts: 8
Replace spaces in log file

Hi

I need to create a script that will convert a log file that is padded with spaces to csv kind of file. for example:

from this:
Code:
test1    test2     test4
12        13         15
to this:
Code:
test1,test2,test4,
12,13,15
Has anyone done this before ?
Reply With Quote
  #2 (permalink)  
Old 10-04-06, 10:12
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
Quote:
Originally Posted by mattlucas
Has anyone done this before ?
I'm sure a lot of people have done this before, e.g. like this:

Code:
sed 's/  */,/g' infile > outfile
or, to edit the file in place:
Code:
ex +'%s/  */,/g|wq' infile
Reply With Quote
  #3 (permalink)  
Old 10-05-06, 02:25
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
or
Code:
tr -s " " "," <infile >outfile
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On