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 9 04-13-2008 07:43 AM
help combining lines in awk blueheed Shell Programming and Scripting 2 03-23-2006 02:26 PM
need help appending lines/combining lines within a file... mr_manny Shell Programming and Scripting 2 01-06-2006 02:45 PM
Combining Multiple files in one in a perl script rahulrathod Shell Programming and Scripting 1 12-17-2005 09: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 (permalink)  
Old 06-04-2008
Registered User
 

Join Date: Jun 2008
Location: US
Posts: 1
Stumble this Post!
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 (permalink)  
Old 06-04-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,928
Stumble this Post!
One way with awk:

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

Join Date: Jun 2008
Posts: 3
Stumble this Post!
Unhappy Good Writting

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

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

Join Date: Jun 2008
Location: PUNE
Posts: 461
Stumble this Post!
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 10:40 PM.


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

Content Relevant URLs by vBSEO 3.2.0