Sponsored Content
Top Forums Shell Programming and Scripting Printing a block of lines from a file, if that block does not contain two patterns using sed Post 302747433 by Scrutinizer on Friday 21st of December 2012 09:33:41 AM
Old 12-21-2012
I don't understand, there is no "11.12.2012" in your sample, I get:
Code:
$ awk 'p{p=p RS $0} /\.\.\.\./ {if(p~s && !(p~/stop/)){print p; p=x}else {p=$0}}' s="12.12.2012" file
................................server 1...............................
running                     process 1
running                     process 2
running                     process 3
date : 12/12/2012
$

Code:
$ awk 'p{p=p RS $0} /\.\.\.\./ {if(p~s && !(p~/stop/)){print p; p=x}else {p=$0}}' s="13.12.2012" file
$

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read block of lines from xml file

Hi I am new to this forum. I have few XML files and from each xml file I want to copy some specific 50 no of lines and copy them to some other file. how to do that? pls help.. (5 Replies)
Discussion started by: pritam1980
5 Replies

2. Shell Programming and Scripting

Replacing Block of lines in a text file

Dear All, Regards of the Day. I have a text file with some functions: Function1 { parameter 1 parameter 2 parameter 3 } end Function2 { parameter 1 parameter 2 parameter 3 } (1 Reply)
Discussion started by: ashisharora
1 Replies

3. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

4. Shell Programming and Scripting

Counting lines in each block file

hello im new here so i want to say hi everybody :) i have to write a script and im newbie :/ i hope that in this forum are many ppl who knows subject :) i have hundrets folders. in each folder is a file name trace.txt. each trace.txt has a lot of tracert's results separates with "-----" it... (6 Replies)
Discussion started by: michael8484
6 Replies

5. Shell Programming and Scripting

Grep between block of lines in a file

Hi Friends, I have a file which has many of the statements like below ******** MAKING > noun1 < cg_all statements statements statements ********* MAKING > noun2 < cg_all statements statements statements ********* MAKING > noun3 < all statements statements statements I would... (3 Replies)
Discussion started by: ganga.dharan
3 Replies

6. UNIX for Dummies Questions & Answers

Printing the lines using search patterns

Hi all , i need an help here.!!!! i have a file that contains /etc/passwd files from some servers. i need a script which search for presence of a user in the servers. like if i give 51144 to the script. the should be o/p Please help on this..... (4 Replies)
Discussion started by: sudharson
4 Replies

7. Shell Programming and Scripting

extracting block of lines from a file

consider the input file which i am dealing with looks like this.. #cat 11.sql create table abc ( . . . ) engine=Innodb ; . . etc . . . create table UsM ( blah blah blah ) engine=Innodb ; (5 Replies)
Discussion started by: vivek d r
5 Replies

8. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

9. Shell Programming and Scripting

Removing a block of duplicate lines from a file

Hi all, I have a file with the data 1 abc 2 123 3 ; 4 rao 5 bell 6 ; 7 call 8 abc 9 123 10 ; 11 rao 12 bell 13 ; (10 Replies)
Discussion started by: raosr020
10 Replies

10. Shell Programming and Scripting

Need awk/sed command to pull out matching lines from a block

Hi, In order to make our debugging easier in log files, I need this script. My log file will be structured like this : ------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013 <multiple lines here> ..... - Step Sybase CDR Table.0 ended... (3 Replies)
Discussion started by: Lakshmikumari
3 Replies
IO::Async::Function(3pm)				User Contributed Perl Documentation				  IO::Async::Function(3pm)

NAME
"IO::Async::Function" - call a function asynchronously SYNOPSIS
use IO::Async::Function; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $function = IO::Async::Function->new( code => sub { my ( $number ) = @_; return is_prime( $number ); }, ); $loop->add( $function ); $function->call( args => [ 123454321 ], on_return => sub { my $isprime = shift; print "123454321 " . ( $isprime ? "is" : "is not" ) . " a prime number "; }, on_error => sub { print STDERR "Cannot determine if it's prime - $_[0] "; }, ); $loop->run; DESCRIPTION
This subclass of IO::Async::Notifier wraps a function body in a collection of worker processes, to allow it to execute independently of the main process. The object acts as a proxy to the function, allowing invocations to be made by passing in arguments, and invoking a continuation in the main process when the function returns. The object represents the function code itself, rather than one specific invocation of it. It can be called multiple times, by the "call" method. Multiple outstanding invocations can be called; they will be dispatched in the order they were queued. If only one worker process is used then results will be returned in the order they were called. If multiple are used, then each request will be sent in the order called, but timing differences between each worker may mean results are returned in a different order. Since the code block will be called multiple times within the same child process, it must take care not to modify any of its state that might affect subsequent calls. Since it executes in a child process, it cannot make any modifications to the state of the parent program. Therefore, all the data required to perform its task must be represented in the call arguments, and all of the result must be represented in the return values. The Function object is implemented using an IO::Async::Routine with two IO::Async::Channel objects to pass calls into and results out from it. The "IO::Async" framework generally provides mechanisms for multiplexing IO tasks between different handles, so there aren't many occasions when such an asynchronous function is necessary. Two cases where this does become useful are: 1. When a large amount of computationally-intensive work needs to be performed (for example, the "is_prime" test in the example in the "SYNOPSIS"). 2. When a blocking OS syscall or library-level function needs to be called, and no nonblocking or asynchronous version is supplied. This is used by "IO::Async::Resolver". This object is ideal for representing "pure" functions; that is, blocks of code which have no stateful effect on the process, and whose result depends only on the arguments passed in. For a more general co-routine ability, see also IO::Async::Routine. PARAMETERS
The following named parameters may be passed to "new" or "configure": code => CODE The body of the function to execute. min_workers => INT max_workers => INT The lower and upper bounds of worker processes to try to keep running. The actual number running at any time will be kept somewhere between these bounds according to load. max_worker_calls => INT Optional. If provided, stop a worker process after it has processed this number of calls. (New workers may be started to replace stopped ones, within the bounds given above). idle_timeout => NUM Optional. If provided, idle worker processes will be shut down after this amount of time, if there are more than "min_workers" of them. exit_on_die => BOOL Optional boolean, controls what happens after the "code" throws an exception. If missing or false, the worker will continue running to process more requests. If true, the worker will be shut down. A new worker might be constructed by the "call" method to replace it, if necessary. setup => ARRAY Optional array reference. Specifies the "setup" key to pass to the underlying IO::Async::Process when setting up new worker processes. METHODS
$function->start Start the worker processes $function->stop Stop the worker processes $function->restart Gracefully stop and restart all the worker processes. $function->call( %params ) Schedules an invocation of the contained function to be executed on one of the worker processes. If a non-busy worker is available now, it will be called immediately. If not, it will be queued and sent to the next free worker that becomes available. The request will already have been serialised by the marshaller, so it will be safe to modify any referenced data structures in the arguments after this call returns. The %params hash takes the following keys: args => ARRAY A reference to the array of arguments to pass to the code. on_result => CODE A continuation that is invoked when the code has been executed. If the code returned normally, it is called as: $on_result->( 'return', @values ) If the code threw an exception, or some other error occured such as a closed connection or the process died, it is called as: $on_result->( 'error', $exception_name ) on_return => CODE and on_error => CODE An alternative to "on_result". Two continuations to use in either of the circumstances given above. They will be called directly, without the leading 'return' or 'error' value. $count = $function->workers Returns the total number of worker processes available $count = $function->workers_busy Returns the number of worker processes that are currently busy $count = $function->workers_idle Returns the number of worker processes that are currently idle NOTES
For the record, 123454321 is 11111 * 11111, a square number, and therefore not prime. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Function(3pm)
All times are GMT -4. The time now is 11:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy