Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Posts
    8

    Unanswered: 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 ?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    or
    Code:
    tr -s " " "," <infile >outfile

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •