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 > Operating Systems > 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 03:47 AM
help combining lines in awk blueheed Shell Programming and Scripting 2 03-23-2006 06:26 PM
need help appending lines/combining lines within a file... mr_manny Shell Programming and Scripting 2 01-06-2006 06:45 PM
Combining Multiple files in one in a perl script rahulrathod Shell Programming and Scripting 1 12-18-2005 01:51 AM
Combining multiple lines DUST Shell Programming and Scripting 4 07-15-2005 10:57 AM

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 Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 06-04-2008
yshahiac yshahiac is offline
Registered User
  
 

Join Date: Jun 2008
Location: US
Posts: 6
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?
  #2 (permalink)  
Old 06-04-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
One way with awk:

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

Join Date: Jun 2008
Posts: 3
Unhappy Good Writting

GOOD WRITTING, NICE WORK...!
  #4 (permalink)  
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
  #5 (permalink)  
Old 08-23-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,391
this is using sed...
Quote:
sed -e 'N;s/\n//g;N;s/\n//g;N;s/\n//g' filename
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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