The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
combining lines in files sme Shell Programming and Scripting 14 10-17-2008 12:47 AM
help combining lines in awk blueheed Shell Programming and Scripting 2 03-23-2006 03:26 PM
need help appending lines/combining lines within a file... mr_manny Shell Programming and Scripting 2 01-06-2006 03:45 PM
Combining Multiple files in one in a perl script rahulrathod Shell Programming and Scripting 1 12-17-2005 10:51 PM
Combining multiple lines DUST Shell Programming and Scripting 4 07-15-2005 07:57 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 06-04-2008
Registered User
 

Join Date: Jun 2008
Location: US
Posts: 1
combining two lines in Linux script

Here is my original file

A07ISALES
12
12
383.G_M_GMX272.HAMTRAMCK.INTERIOR_TRIM.32949

I want to convert it to

A.07.ISALES.12.383.G_M_GMX272.HAMTRAMCK.INTERIOR_TRIM.32949

Basically, from first record, I separate the characters, add period and concatenate to rest of the records in file. Remove the record. From second record, concatenate the value and add the period. Remove second and third record. This should be added to all the records too.

How can I do this using sed command inside the script from input file?
Reply With Quote
Forum Sponsor
  #2  
Old 06-04-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,199
One way with awk:

Code:
awk '{s=NR==1?"":"."}{printf("%s%s",s,$0)}END{print ""}' file
Regards
Reply With Quote
  #3  
Old 06-17-2008
Banned
 

Join Date: Jun 2008
Posts: 3
Unhappy Good Writting

GOOD WRITTING, NICE WORK...!
Reply With Quote
  #4  
Old 08-23-2008
rc7 rc7 is offline
Registered User
 

Join Date: Aug 2008
Posts: 4
Another (simpler) way of using awk:
Code:
awk 'BEGIN{FS="\n";RS="";OFS="."} {print $1,$2,$3,$4}' file
Reply With Quote
  #5  
Old 08-23-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 537
this is using sed...
Quote:
sed -e 'N;s/\n//g;N;s/\n//g;N;s/\n//g' filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:55 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