Sponsored Content
Top Forums UNIX for Dummies Questions & Answers sed or grep or perl combine two lines Post 37758 by artjaniger on Friday 27th of June 2003 01:09:25 PM
Old 06-27-2003
i have a large file with embedded sequential lines containing the word "expected" or "received":
for example
line 1 some data
line 2 some more data
line 3 123expected456
line 4 123received456
line 5 more data
line 6 more data
line 7 123expected
line 8 456 expected
line 9 777 received
I want to capture lines 3 and 4, lines 8 and 9
(i. e., 2 lines in a row, the first containing expected,
the second containing received)
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SImple HELP! how to combine two lines together using sed or awk..

hi..im new to UNIX... ok i have this information in the normal shell... there are 2 lines display like this: h@hotmail.com k@hotmail.com i want it to display like this with a space betweem them h@hotmail.com k@hotmail.com the information is stored in a text file.... anyone... (10 Replies)
Discussion started by: forevercalz
10 Replies

2. Shell Programming and Scripting

sed, grep, cut or combine?

I am a beginner at shell scripting, actually i am working on my first script right now. Anyway i have searched the world how to grep two letters from each word (it will always just be two words). For example: Example Blablabla I want my script to cut out Ex (from the first word) and Bl... (4 Replies)
Discussion started by: maskot
4 Replies

3. Shell Programming and Scripting

[Help] PERL Script - grep multiple lines

Hi Gurus, I need some help with the "grep" command or whatever command that you think suitable for me. I'm about to write a perl script to extract a report from the system and submit it to the end users. The input for the script will consist of 3 element. 1) Generation ID 2) Month 3) Year... (6 Replies)
Discussion started by: miskin
6 Replies

4. Shell Programming and Scripting

Like grep -v for a string over 2 lines? Sed?

Hi, I have a log file that I need to monitor as it's being written to, and I want to exclude certain strings from the output. At the moment I'm using ... tail -f LogFileName_`date +%d`.log | egrep -v "First String To Exclude | 2nd string | 3rd string" ...which works OK - but now I need to... (1 Reply)
Discussion started by: jake657
1 Replies

5. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

6. Shell Programming and Scripting

Sed grep the first matched lines

Hi I have a myfile.txt contains the following: CONTEXT { AAAAA } ... CONTEXT { BBBBB } I want to extract the lines in between CONTEXT { ... }, one by one. Hence I wrote a command like the following, sed -n '/^CONTENT/,/^}/ { w a.txt }' myfile.txt The problem with this... (5 Replies)
Discussion started by: hezjing
5 Replies

7. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

8. Shell Programming and Scripting

grep/sed to remove lines in file

Hi, I have a file with values, file1: BELL-1180-1180-81|577:1017| BELL-1180-1180-81|jm10i-auto-stub1/577:102| BELL-1180-1180-81|jm10i-auto-stub1/577:101| BELL-1180-1180-81|jm10i-auto-stub1/577:1700| BELL-1180-1180-81|jm10i-auto-stub1/577:1699| I need to remove the lines which has... (9 Replies)
Discussion started by: giri_luck
9 Replies

9. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

10. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies
HTTP::Proxy::BodyFilter::lines(3pm)			User Contributed Perl Documentation		       HTTP::Proxy::BodyFilter::lines(3pm)

NAME
HTTP::Proxy::BodyFilter::lines - A filter that outputs only complete lines SYNOPSIS
use HTTP::Proxy::BodyFilter::lines; use MyFilter; # this filter only works on complete lines my $filter = MyFilter->new(); # stack both filters so that they'll handle text/* responses $proxy->push_filter( mime => 'text/*', response => HTTP::Proxy::BodyFilter::lines->new, response => $filter ); # I want my lines to end with '!' # This is equivalent to $/ = '!' in a normal Perl program my $lines = HTTP::Proxy::BodyFilter::lines->new('!'); DESCRIPTION
The HTTP::Proxy::BodyFilter::lines filter makes sure that the next filter in the filter chain will only receive complete lines. The "chunks" of data received by the following filters with either end with " " or will be the last piece of data for the current HTTP message body. You can change the idea the filter has of what is a line by passing to its constructor the string it should understand as line ending. " " is the default value. my $filter = HTTP::Proxy::BodyFilter::lines->new( $sep ); This is similar to modifying $/ in a Perl program. In fact, this filter has a behaviour so similar to modifying $/ that it also knows about "paragraph mode" and "record mode". Note that the "slurp" mode is not supported. Please use HTTP::Proxy::BodyFilter::complete to enable the generic store and forward filter mechanism. METHODS
This filter defines the following methods, which are automatically called: init() Initialise the filter with the EOL information. filter() Keeps unfinished lines for later. will_modify() This method returns a false value, thus indicating to the system that it will not modify data passing through. SEE ALSO
HTTP::Proxy, HTTP::Proxy::BodyFilter. AUTHOR
Philippe "BooK" Bruhat, <book@cpan.org>. COPYRIGHT
Copyright 2003-2006, Philippe Bruhat. LICENSE
This module is free software; you can redistribute it or modify it under the same terms as Perl itself. perl v5.12.4 2011-07-03 HTTP::Proxy::BodyFilter::lines(3pm)
All times are GMT -4. The time now is 10:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy