Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Question Unanswered: Cocatenating two lines to one in a file...

    Hi,

    How can I concat two lines to one in a file? Easy question I think but didn't find the answer with search..

    xxx,xxx,xxx,xxx
    yyy,yyy,yyy

    ->

    xxx,xxx,xxx,xxx,yyy,yyy,yyy


    -M-

  2. #2
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    If your file is like this sample.

    hello hello hello
    fine fine fine
    xxxxxxx xxxxxxx
    fine fine fine

    and you want this result:

    hello hello hellofine fine fine
    xxxxxxx xxxxxxxfine fine fine

    then use this:

    awk 'BEGIN{i=1}{i=i*(-1); if (i==-1) printf $0;else print $0}' filename

    bye,
    ducasio

  3. #3
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    paste - - < file
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

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