![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#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? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
One way with awk:
Code:
awk '{s=NR==1?"":"."}{printf("%s%s",s,$0)}END{print ""}' file
|
|
#3
|
|||
|
|||
|
GOOD WRITTING, NICE WORK...!
|
|
#4
|
|||
|
|||
|
Another (simpler) way of using awk:
Code:
awk 'BEGIN{FS="\n";RS="";OFS="."} {print $1,$2,$3,$4}' file
|
|
#5
|
||||
|
||||
|
this is using sed...
Quote:
|
||||
| Google The UNIX and Linux Forums |