Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Grep and display n lines after the match is found. Post 302240293 by cv_pan on Thursday 25th of September 2008 10:54:52 AM
Old 09-25-2008
Grep and display n lines after the match is found.

Hello,
How do I use grep to find a pattern in a list of file and then display 5 lines after the pattern is matched

Eg:
I want to match the string GetPresentCode in all files in a folder and then see 4 lines following this match. I am not sure if grep is what should be used to achieve. Thanks!


#Method
GetPresentCode Behaviours
#Return Type
string
#Method Body
return pPresent.code
#User Tags
_DI_LABEL = editonly "--_Transaction code?"
_DI_DESCRIPTION = editonly ""
_DI_TYPE = editonly "Condition"

output as:
GetPresentCode Behaviours
#Return Type
string
#Method Body
return pPresent.code
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to prevent grep command from throwing a system trap if No match is found.

Hi How to prevent grep command from throwing a system trap(or returning error status) if No match is found in the specified file(s) ? Consider this simple shell script: #!/usr/bin/ksh trap 'STATUS=$?;set +x;echo;echo error $STATUS at line nb $LINENO executing :\ `sed -n... (2 Replies)
Discussion started by: cool.aquarian
2 Replies

2. Shell Programming and Scripting

How to grep for message and if found display filename?

Hi i'm new to the forum and was hoping someone could help me with the following query. I do alot of testing and have hundreds of log files output. I have a script (someone else wrote) which finds all the passed and failed logs and puts a number in a column onto a webpage: e.g: Pass ... (4 Replies)
Discussion started by: defamer
4 Replies

3. Shell Programming and Scripting

kill a process if grep match is found

Hi, I need something unusual, I guess. I need to start a process, and if that process displays a specific error message, I need to kill that process and restart it. Something like: startprocess | grep -i "This is the specific error message" && kill $pidof(startprocess) Explanation, I need... (4 Replies)
Discussion started by: burek
4 Replies

4. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

5. UNIX for Dummies Questions & Answers

Display n lines before match found

I have a file with following data A B C D E F G H I K L M N and search pattern is G Expected output (3 Replies)
Discussion started by: nsuresh316
3 Replies

6. UNIX for Dummies Questions & Answers

Display n lines after match found and other line

I have a file like this DoctorName Address1 Address2 DOB InsuredName Address1 Address2 DOB PatientName Address1 Address2 DOB ClaimNo1 DoctorName Address1 Address2 DOB InsuredName (2 Replies)
Discussion started by: nsuresh316
2 Replies

7. UNIX for Dummies Questions & Answers

Display lines after match is found within specified range

I have a file which has collection of segments occuring n(For eg.100) times ISA GS ST NM1*85 N3 N4 NM1*IL N3 N4 REF*D9*1001 ISE GE SE ISA GS ST NM1*85 N3 (13 Replies)
Discussion started by: nsuresh316
13 Replies

8. Shell Programming and Scripting

Grep multiple exact match, do not display lines

Hi, Need help to grep the following from a file x. I just want to grep exact match not lines and not partial word. CONFSUCCESS CONFFAIL CONFPARTIALSUCCESS >cat x xczxczxczc zczczcxx CONFSUCCESS czczczcczc czxxczxzxczcczc CONFFAIL xczxczcxcczczc zczczczcz CONFPARTIALSUCCESS czczxcxzc ... (4 Replies)
Discussion started by: rajeshwebspere
4 Replies

9. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

10. Shell Programming and Scripting

Grep everything between two pattern if match not found

I need to help to work this Print everything between 2 patterns if grep is not found the search word example Detroit orange cat bat rat apple sed -n "/Detroit,/apple/p" d |grep chicago output would be Detroit orange cat bat rat (1 Reply)
Discussion started by: jhonnyrip
1 Replies
Pod::WSDL::Method(3pm)					User Contributed Perl Documentation				    Pod::WSDL::Method(3pm)

NAME
Pod::WSDL::Method - Represents a method in Pod::WSDL (internal use only) SYNOPSIS
use Pod::WSDL::Method; my $m = new Pod::WSDL::Method(name => 'mySub', writer => 'myWriter', doc => new Pod::WSDL::Doc($docStr), return => new Pod::WSDL::Return($retStr)); DESCRIPTION
This module is used internally by Pod::WSDL. It is unlikely that you have to interact directly with it. If that is the case, take a look at the code, it is rather simple. METHODS
new Instantiates a new Pod::WSDL::Method. Parameters o name - name of the method, mandatory o doc - a Pod::WSDL::Doc object, can be ommitted, use method doc later o return - a Pod::WSDL::Return object, can be ommitted, use method return later o params - ref to array of Pod::WSDL::Param objects, can be ommitted, use addParam() later o faults - ref to array of Pod::WSDL::Fault objects, can be ommitted, use addFault() later o oneway - if true, method is a one way operation o writer - XML::Writer-Object for output, mandatory addParam Add a Pod::WSDL::Param object to Pod::WSDL::Method addFault Add a Pod::WSDL::Fault object to Pod::WSDL::Method return Get or Set the Pod::WSDL::Return object for Pod::WSDL::Method doc Get or Set the Pod::WSDL::Doc object for Pod::WSDL::Method requestName Get name for request in XML output responseName Get name for response in XML output writeBindingOperation Write operation child for binding element in XML output writeMessages Write message elements in XML output writePortTypeOperation Write operation child for porttype element in XML output EXTERNAL DEPENDENCIES
[none] EXAMPLES
see Pod::WSDL BUGS
see Pod::WSDL TODO
see Pod::WSDL SEE ALSO
Pod::WSDL :-) AUTHOR
Tarek Ahmed, <bloerch -the character every email address contains- oelbsk.org> COPYRIGHT AND LICENSE
Copyright (C) 2006 by Tarek Ahmed This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. perl v5.10.1 2010-12-18 Pod::WSDL::Method(3pm)
All times are GMT -4. The time now is 02:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy