Sponsored Content
Top Forums Shell Programming and Scripting Print first and last line from multiline record Post 302640657 by Catullus on Tuesday 15th of May 2012 07:48:21 AM
Old 05-15-2012
Print first and last line from multiline record

Hi - I'm new to working with multiline records and I'm going nuts trying to do something that seems simple.

Input:
Code:
Tue May 1 14:00 Header Record 1 is valid.
Tue May 1 14:00 processing data to 25-Mar-2012 09:00:23.15
Tue May 1 14:03 Header Record 1 is valid.
Tue May 1 14:03 processing data to 25-Mar-2012 09:05:12.19
Tue May 1 14:04 processing data to 25-Mar-2012 09:06:23.67
Tue May 1 14:04 processing data to 25-Mar-2012 09:06:24.72
Tue May 1 14:05 Header Record 1 is valid.
Tue May 1 14:05 processing data to 25-Mar-2012 09:06:33.02
Tue May 1 14:08 processing data to 25-Mar-2012 09:12:34.24

What I'd like to see is this:
Code:
Tue May 1 14:00 Header Record 1 is valid. @ Tue May 1 14:00 processing data to 25-Mar-2012 09:00:23.15
Tue May 1 14:03 Header Record 1 is valid. @ Tue May 1 14:04 processing data to 25-Mar-2012 09:06:24.72
Tue May 1 14:05 Header Record 1 is valid. @ Tue May 1 14:08 processing data to 25-Mar-2012 09:12:34.24

Moderator's Comments:
Mod Comment Code tags please

i.e. each record starts with the header record and ends with the last processing data line, but only print the header record, some delimiter then the final field of the record.

I tried this:
Code:
BEGIN {
    FS="\n"
    RS="@"
}
{ print $1 "@" $NF }

but it only prints the very first line of the file, then all the final record lines.

Can someone tell me where I'm going wrong.

Thanks

Last edited by Scrutinizer; 05-15-2012 at 09:01 AM.. Reason: Please use code tags - again
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

transforming a multiline record to single line

Hi All I have a file like this <LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText> <LText>gvsvdkag<LREC>bdj vdj</LREC>nididyvv</LText> <LText>gvsvdkag<LREC>b djvdj</LREC>nididyvv</LText> <LText>gvsvdkag<LREC>bdjvdj</LREC>nididyvv</LText> How will i change the file to ... (9 Replies)
Discussion started by: anju
9 Replies

2. UNIX for Advanced & Expert Users

Print Full record and substring in that record

I have i got a requirement like below. I have input file which contains following fixed width records. 00000000000088500232007112007111 I need the full record and concatenated with ~ and characters from 1to 5 and concatenated with ~ and charactes from 10 to 15 The out put will be like... (1 Reply)
Discussion started by: ukatru
1 Replies

3. Shell Programming and Scripting

Awk Multiline Record Combine?

I'm trying to use Awk to get the id and name fields ($1 and $2) of file1 combined with their corresponding multiline records in file2 that are separated by blank line. Both files are ordered so that the first line of file1 corresponds to the first set of multiline records in file2 and so on. ... (4 Replies)
Discussion started by: RacerX
4 Replies

4. Shell Programming and Scripting

Multiline read with multicharacter record seperator

I have a file like the below: Start <</NumCopies 0001>> 0223 098 et(5926)sh 0223 098 mt(5926)sh End Start <</NumCopies 0001>> 0224 098 et(5926)sh 0224 098 mt(5926)sh End This file needs to be split to seperate files. Each of the seperate file will need to... (3 Replies)
Discussion started by: pt14
3 Replies

5. Shell Programming and Scripting

Regarding multiline record searching with specific pattern

Dear Experts, I need to extract specific records from one file which has multiline records. Input file pattern is: ============ aaaaaaaa bbbbbbbb asdf 1234 cccccccc dddddddd ============ aaaaaaaa bbbbbbbb qwer 2345 cccccccc dddddddd (7 Replies)
Discussion started by: dhiraj4mann
7 Replies

6. Shell Programming and Scripting

Reject the record if the record in the next line does not satisfy the pattern

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten The output should be 1one 2two 3three 1four 2five 3six (2 Replies)
Discussion started by: supchand
2 Replies

7. Shell Programming and Scripting

Reject the record if the record in the next line does not begin with 2.

Hi, I have a input file with the following entries: 1one 2two 3three 1four 2five 3six 1seven 1eight 1nine 2ten 2eleven 2twelve 1thirteen 2fourteen The output should be: (5 Replies)
Discussion started by: supchand
5 Replies

8. Shell Programming and Scripting

Help with print out line that have different record in specific column

Input file 1: - 7367 8198 - 8225 9383 + 9570 10353 Input file 2: - 2917 3667 - 3851 4250 + 4517 6302 + 6302 6740 + 6768 7524 + 7648 8170 + 8272 8896 + 8908 9915 - 10010 ... (18 Replies)
Discussion started by: perl_beginner
18 Replies

9. Shell Programming and Scripting

Help with print out record if first and next line follow specific pattern

Input file: pattern1 100 250 US pattern2 50 3050 UK pattern3 100 250 US pattern1 70 1050 UK pattern1 170 450 Mal pattern2 40 750 UK . . Desired Output file: pattern1 100 250 US pattern2 50 3050 UK pattern1 170 450 Mal pattern2... (3 Replies)
Discussion started by: cpp_beginner
3 Replies

10. Shell Programming and Scripting

Combine multiline to one line till a blank line

Hello, I have a file as :- ABC DEF GHI JKL <BlankLine> MNO PQR STU VWX <BlankLine> YZA I need it as below:- ABCDEFGHIJKL; MNOPQRSTUVWX; (3 Replies)
Discussion started by: jassi10781
3 Replies
LineComp(3U)						    InterViews Reference Manual 					      LineComp(3U)

NAME
LineComp, LineView, PSLine, MultiLineComp, MultiLineView, PSMultiLine - line and multiline component subject, view, and PostScript external representation SYNOPSIS
#include <Unidraw/Components/line.h> DESCRIPTION
LineComp is a GraphicComp that defines a line. It uses an Line graphic to store its graphical attributes. LineView is a GraphicView for displaying the line. PSLine is a PostScriptView that externalizes the subject's information in PostScript form. The MultiLine counter- parts of these classes define the component and external representation for a contiguous set of line segments, i.e., an open polygon. Mul- tiLineComp is derived from VerticesComp, MultiLineView is a VerticesView, and PSMultiLine is a PSVertices. LINECOMP PUBLIC OPERATIONS
LineComp(Line* = nil) The constructor takes an optional line graphic that defines the attributes of the line. virtual void Interpret(Command*) LineComp redefines Interpret to ignore PatternCmds. Line* GetLine() Return the Line graphic that defines the line's attributes. GetLine is simply a more specific form of the GetGraphic operation. LINEVIEW PUBLIC OPERATIONS
LineView(LineComp* = nil) Create an LineView, optionally supplying the subject. virtual void Interpret(Command*) LineView interprets AlignToGridCmd to align its first endpoint to the grid. virtual Manipulator* CreateManipulator( Viewer*, Event&, Transformer*, Tool* ) virtual void InterpretManipulator(Manipulator*) LineView redefines its response to manipulation with a GraphicCompTool. The user clicks to specify the first endpoint of the line and then drags to position remaining endpoint. The endpoints will be constrained by gravity, if any. LineView also defines a response to the ReshapeTool, allowing the user to click on one of its endpoints to reposition it. The subject is actually replaced (via ReplaceCmd) with a new LineComp subject reflecting the repositioned endpoint. Repositioning will be influenced by gravity. virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&) Return the line's endpoints, in canvas coordinates. LineComp* GetLineComp() Return the subject. LINEVIEW PROTECTED OPERATIONS
virtual void CreateHandles() LineView redefines CreateHandles to use a RubberHandles object with two handles, one at each endpoint of the line. PSLINE PUBLIC OPERATIONS
PSLine(LineComp* = nil) Construct a PostScript external representation of the given subject, if any. MULTILINECOMP PUBLIC OPERATIONS
MultiLineComp(SF_MultiLine* = nil) The constructor takes an optional stroked-filled multiline graphic that defines the attributes of the multiline. SF_MultiLine* GetMultiLine() Return the MultiLine graphic that defines the multiline's attributes. GetMultiLine is simply a more specific form of the GetGraphic operation. MULTILINEVIEW PUBLIC OPERATIONS
MultiLineView(MultiLineComp* = nil) Create an MultiLineView, optionally supplying the subject. virtual Manipulator* CreateManipulator( Viewer*, Event&, Transformer*, Tool* ) virtual void InterpretManipulator(Manipulator*) MultiLineView redefines its response to manipulation with a GraphicCompTool. The user clicks the left mouse button to specify each vertex and clicks with the middle mouse button to specify the final vertex. Vertex positioning will be constrained by gravity, if any. MultiLineView also defines a response to the ReshapeTool, allowing the user to click on one of its vertices to reposition it. The subject is actually replaced (via ReplaceCmd) with a new MultiLineComp subject reflecting the repositioned vertex. Reposition- ing will be influenced by gravity. MultiLineComp* GetMultiLineComp() Return the subject. PSMULTILINE PUBLIC OPERATIONS
PSMultiLine(MultiLineComp* = nil) Construct a PostScript external representation of the given subject, if any. PSMULTILINE PROTECTED OPERATIONS
virtual const char* Name() PSMultiLine identifies itself as "MLine" in the PostScript output. SEE ALSO
Event(3I), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PatternCmd(3U), PostScriptView(3U), ReshapeTool(3U), Rub- band(3I), Transformer(3I), VerticesComp(3U), Viewer(3U), align(3U), edit(3U), lines(3U) Unidraw 22 January 1991 LineComp(3U)
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy