The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-14-2007
jithinravi jithinravi is offline
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?
  #2 (permalink)  
Old 05-14-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
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 09:31 AM..
  #3 (permalink)  
Old 05-14-2007
jithinravi jithinravi is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 8
nope sorry!! it says pate command not found.
  #4 (permalink)  
Old 05-14-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,518
Code:
tr '\n' ',' < file
  #5 (permalink)  
Old 05-15-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0