Sponsored Content
Top Forums Shell Programming and Scripting Merging 2 lines based on a string Post 302934125 by Karunyam on Wednesday 4th of February 2015 09:52:46 PM
Old 02-04-2015
Merging 2 lines based on a string

Dear Unix gurus

I need help with a command or script to merge 2 lines where ever we find the string.

I have attached scanned document.

First line has string value: VSIN, immediate line has value: SETTLEMENT

Where it finds the 2 string values in the whole file, one below the other, those 2 lines to be merged into a single line and the other detail data lines has to be remained in the same order.


E.g.:

Code:
Line1: VSIN .... (Space) SETTLEMENT CURRENCY ....
Line2: other detail data in the same order 
Line3: VJRE ...
Line4: VJRE ...
Line5: VSIN .... (Space) SETTLEMENT CURRENCY ....
Line6: VJRE ....
Line7: VJRE ....
Line8: VJRE...
Line9: VSIN. ...(Space) SETTLEMENT CURRENCY....
....
....

Many thanks
Your help is much appreciated as I am not a core Unix programmer.
Many thanks
Karunya
Merging 2 lines based on a string-imagejpg

Last edited by Scrutinizer; 02-05-2015 at 01:10 AM.. Reason: code tags, removed quote tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

searching and storing unknown number of lines based on the string with a condition

Dear friends, Please help me to resolve the problem below, I have a file with following content: date of file creation : 12 feb 2007 ==================== = name : suresh = city :mumbai #this is a blank line = date : 1st Nov 2005 ==================== few lines of some text this... (7 Replies)
Discussion started by: swamymns
7 Replies

2. Shell Programming and Scripting

Merging lines based on occurances of a particular character in a file

Hi, Is there any way to merge two lines based on specific occurance of a character in a file. I am having a flat file which contains multiple records. Each row in the file should contain specified number of delimiter. For a particular row , if the delimiter count is not matched with... (2 Replies)
Discussion started by: mohan_tuty
2 Replies

3. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

4. Shell Programming and Scripting

Multi line document to single lines based on occurance of string

Hi Guys, I am new to awk and sed, i am working multiline document, i want to make make that document into SINGLE lines based on occurace of string "dwh". here's the sample of my problem.. dwh123 2563 4562 4236 1236 78956 12394 4552 dwh192 2656 46536 231326 65652 6565 23262 16625623... (5 Replies)
Discussion started by: victor369
5 Replies

5. Shell Programming and Scripting

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 Replies

6. Shell Programming and Scripting

Merging Lines based on criteria

Hello, Need help with following scenario. A file contains following text: {beginning of file} New: This is a new record and it is not on same line. Since I have lost touch with script take this challenge and bring all this in one line. New: Hello losttouch. You seem to be struggling... (4 Replies)
Discussion started by: losttouch
4 Replies

7. UNIX for Dummies Questions & Answers

Remove lines in a positional file based on string value

Gurus, I am relatively new to Unix scripting and am struck with a problem in my script. I have positional input file which has a FLAG indicator in at position 11 in every record of the file. If the Flag has value =Y, then the record from the input needs to be written to a new file.However if... (3 Replies)
Discussion started by: gsam
3 Replies

8. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

9. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

10. UNIX for Beginners Questions & Answers

Merging multiple lines into single line based on one column

I Want to merge multiple lines based on the 1st field and keep into single record. SRC File: AAA_POC_DB.TAB1 AAA_POC_DB.TAB2 AAA_POC_DB.TAB3 AAA_POC_DB.TAB4 BBB_POC_DB.TAB1 BBB_POC_DB.TAB2 CCC_POC_DB.TAB6 OUTPUT ----------------- 'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'... (10 Replies)
Discussion started by: raju2016
10 Replies
Compound(3)						User Contributed Perl Documentation					       Compound(3)

NAME
Tk::Compound - Create multi-line compound images. SYNOPSIS
use Tk::Compound; $image = $widget->Compound(name,options); $image->Line(options); $image->Text(options); $image->Bitmap(options); $image->Image(options); $image->Space(options); DESCRIPTION
Compound image types can be used to create images that consists of multiple horizontal lines; each line is composed of a series of items (texts, bitmaps, images or spaces) arranged from left to right. Compound images are mainly used to embed complex drawings into widgets that support the -image option. As shown in the EXAMPLE section below, a compound image can be used to display a bitmap and a text string simutaneously in a Tk Button widget. Compound images can only be used on windows on the same display as, and with the same pixel depth and visual as the $widget used to create them. CREATING COMPOUND IMAGES
Compounds are created using $widget->Compound. Compounds support the following options: -background => color Specifies the background color of the compound image. This color is also used as the default background color for the bitmap items in the compound image. -borderwidth => pixels Specifies a non-negative value indicating the width of the 3-D border drawn around the compound image. -font => font Specifies the default font for the text items in the compound image. -foreground => color Specifies the default foreground color for the bitmap and text items in the compound image. -padx => value Specifies a non-negative value indicating how much extra space to request for the compound image in the X-direction. The value may have any of the forms acceptable to Tk_GetPixels(3). -pady => value Specifies a non-negative value indicating how much extra space to request for the compound image in the Y-direction. -relief => value Specifies the 3-D effect desired for the background of the compound image. Acceptable values are raised, sunken, flat, ridge, and groove. -showbackground => value Specifies whether the background and the 3D borders should be drawn. Must be a valid boolean value. By default the background is not drawn and the compound image appears to have a transparent background. IMAGE COMMAND
When a compound image is created, Tk also creates a new object. This object supports the configure and cget methods described in Tk::options which can be used to enquire and modify the options described above. The object also supports the following methods: $compound->Line?(option = value ...>)? Creates a new line at the bottom of the compound image. Lines support the following options: -anchor value Specifies how the line should be aligned along the horizontal axis. When the values are w, sw or nw, the line is aligned to the left. When the values are c, s or n, the line is aligned to the middle. When the values are e, se or ne, the line is aligned to the right. -padx => value Specifies a non-negative value indicating how much extra space to request for this line in the X-direction. $compound->Itemtype?(option = value ...>)? Creates a new item of the type Itemtype at the end of the last line of the compound image. All types of items support these following common options: -anchor value Specifies how the item should be aligned along the vertical axis. When the values are n, nw or ne, the item is aligned to the top of the line. When the values are c, w or e, the item is aligned to the middle of the line. When the values are s, se or sw, the item is aligned to the bottom of the line. -padx => value Specifies a non-negative value indicating how much extra space to request for this item in the X-direction. -pady => value Specifies a non-negative value indicating how much extra space to request for this item in the Y-direction. item-type can be any of the following: $compound->Bitmap?(option = value ...>)? Creates a new bitmap item of at the end of the last line of the compound image. Additional options accepted by the bitmap type are: -background => color Specifies the background color of the bitmap item. -bitmap => name Specifies a bitmap to display in this item, in any of the forms acceptable to Tk_GetBitmap(3). -foreground => color Specifies the foreground color of the bitmap item. $compound->Image?(option = value ...>)? Creates a new image item of at the end of the last line of the compound image. Additional options accepted by the image type are: -image => name Specifies an image to display in this item. name must have been created with the image create command. $compound->Space?(option = value ...>)? Creates a new space item of at the end of the last line of the compound image. Space items do not display anything. They just acts as space holders that add additional spaces between items inside a compound image. Additional options accepted by the image type are: -width => value Specifies the width of this space. The value may have any of the forms acceptable to Tk_GetPixels(3). -height => value Specifies the height of this space. The value may have any of the forms acceptable to Tk_GetPixels(3). $compound->Text?(option = value ...>)? Creates a new text item of at the end of the last line of the compound image. Additional options accepted by the text type are: -background => color Specifies the background color of the text item. -font => name Specifies the font to be used for this text item. -foreground => color Specifies the foreground color of the text item. -justify value When there are multiple lines of text displayed in a text item, this option determines how the lines line up with each other. value must be one of left, center, or right. Left means that the lines' left edges all line up, center means that the lines' centers are aligned, and right means that the lines' right edges line up. -text => string Specifies a text string to display in this text item. -underline value Specifies the integer index of a character to underline in the text item. 0 corresponds to the first character of the text displayed in the text item, 1 to the next character, and so on. -wraplength value This option specifies the maximum line length of the label string on this text item. If the line length of the label string exceeds this length, it is wrapped onto the next line, so that no line is longer than the specified length. The value may be specified in any of the standard forms for screen distances. If this value is less than or equal to 0 then no wrapping is done: lines will break only at newline characters in the text. EXAMPLE
The following example creates a compound image with a bitmap and a text string and places this image into a Button(n) widget. Notice that the image must be created using the widget that it resides in. my $b = $parent->Button; my $c = $b->Compound; $b->configure(-image => $c); $c->Line; $c->Bitmap(-bitmap => 'warning'); $c->Space(-width => 8); $c->Text(-text => "Warning", -underline => 0); $b->pack; KEYWORDS
image(n), Tix(n) perl v5.12.1 2007-05-05 Compound(3)
All times are GMT -4. The time now is 11:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy