The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-14-2007
Registered User
 

Join Date: Apr 2007
Posts: 8
SED again...

hi could u tell me how to use sed for the following issue:

i have 2 files A and B . A has say 100lines:
line1
line2
line3
.
.
.
line100

i want to read data from file A and save it in file B as :
line1, line2, line3, ... line99, line100

that is in a single line.
What is the best way to do this...i thought of using the sed command
sed -i '1,$s/$/" parameter "/' fileB

but cudnt get how to read the text from fileA and pass it as a paramete to the Sed command?
Reply With Quote
Forum Sponsor
  #2  
Old 05-14-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Jithinravi,
Sorry, my mistake, it is "paste" with the "s":
Code:
paste -s - < fileA > fileB

Last edited by Shell_Life; 05-14-2007 at 06:31 AM.
Reply With Quote
  #3  
Old 05-14-2007
Registered User
 

Join Date: Apr 2007
Posts: 8
nope sorry!! it says pate command not found.
Reply With Quote
  #4  
Old 05-14-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
tr '\n' ',' < file
Reply With Quote
  #5  
Old 05-14-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by jithinravi
hi could u tell me how to use sed for the following issue:

i have 2 files A and B . A has say 100lines:
line1
line2
line3
.
.
.
line100

i want to read data from file A and save it in file B as :
line1, line2, line3, ... line99, line100

that is in a single line.
What is the best way to do this...i thought of using the sed command
sed -i '1,$s/$/" parameter "/' fileB

but cudnt get how to read the text from fileA and pass it as a paramete to the Sed command?
Code:
sed -n -e :a -e 'N;s/\n/, /;$p;b a' fileA > fileB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0