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 > Cocatenating two lines to one in a file...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-21-05, 08:10
tmikahan tmikahan is offline
Registered User
 
Join Date: Aug 2004
Posts: 2
Question 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-
Reply With Quote
  #2 (permalink)  
Old 02-21-05, 10:22
ducasio ducasio is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 02-21-05, 10:42
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
paste - - < file
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
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