Sponsored Content
Top Forums Shell Programming and Scripting Perl script to match a pattern and print lines Post 302269874 by FlyingSquirrel on Thursday 18th of December 2008 11:59:58 PM
Old 12-19-2008
ammu,

Try this script, if it were called... myscript.pl
chmod 755 myscript.pl
cat file1 | ./myscript.pl



#!/usr/bin/env perl

$p=0;
$c=0;
while (<STDIN>) {
if ($p == 0 && m/ERROR/) {
$p=1;
$c=$. + 10;
}

if ($p == 1) {
if ($. < $c) {
print $_;
} else {
last;
}
}
}
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Printing Multiple Lines after pattern match

Hello People, Need some assistance/guidance. OUTLINE: Two files (File1 and File2) File1 has some ids such as 009463_3922_1827 897654_8764_5432 File2 has things along the lines of: Query= 009463_3922_1827 length=252 (252 letters) More stufff here ... (5 Replies)
Discussion started by: Deep9000
5 Replies

2. Shell Programming and Scripting

sed print all lines after pattern match

HiCan someone show me how to print all lines from a file after a line matching a pattern using sed?Thanks (13 Replies)
Discussion started by: steadyonabix
13 Replies

3. Shell Programming and Scripting

print chunk of lines only if there is a pattern match in between them

Hi All, Please find the sample file below: NAME ID NUMBER -------------------------------------------------------------------------------------------------- --------- abcdefgheija;lksdf ... (13 Replies)
Discussion started by: niel.verty
13 Replies

4. Shell Programming and Scripting

print lines with exact pattern match

I have in a file domain.com. 1909 IN A 1.22.33.44 domain.com. 1909 IN A 22.33.44.55 ns1.domain.com. 1699 IN A 33.44.55.66 ns2.domain.com. 1806 IN A 77.77.66.66 I need to "grep" or "awk" out the lines starting with domain.com. as follows. domain.com. 1909 IN A 1.22.33.44 domain.com.... (3 Replies)
Discussion started by: anilcliff
3 Replies

5. Shell Programming and Scripting

perl script print the lines between two pattern

i have a file as below sample.pl parameter1 argument1 argument2 parameter2 I want out as below argument1 argument2 that is , i want to print all the lines between parameter1 & parameter 2. i tried with the following if($mystring =~ m/parameter1(.*?)parameter2/) (2 Replies)
Discussion started by: roopa
2 Replies

6. Shell Programming and Scripting

Print lines before and after pattern match

I am using Solaris, I want to print 3 lines before pattern match pattern 5 lines after pattern match Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks .. Input File a.txt: ================= 1 2 3 abcd 4 5 6 7 8 (7 Replies)
Discussion started by: manuswami
7 Replies

7. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

8. Shell Programming and Scripting

Print lines that do not match the pattern

I need to print the lines that do not match a pattern. I tried using grep -v and sed -n '/pattern/!p', but both of them are not working as I am passing the pattern as variable and it can be null some times. Example ........ abcd...... .........abcd...... .........abcd......... (4 Replies)
Discussion started by: sunny1234
4 Replies

9. Shell Programming and Scripting

awk print pattern match line and following lines

Data: Pattern Data Data Data Data Data Data Data Data Data ... With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
Discussion started by: dmesserly
9 Replies

10. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies
decrypt(3)						User Contributed Perl Documentation						decrypt(3)

NAME
Filter::decrypt - template for a decrypt source filter SYNOPSIS
use Filter::decrypt ; DESCRIPTION
This is a sample decrypting source filter. Although this is a fully functional source filter and it does implement a very simple decrypt algorithm, it is not intended to be used as it is supplied. Consider it to be a template which you can combine with a proper decryption algorithm to develop your own decryption fil- ter. WARNING
It is important to note that a decryption filter can never provide complete security against attack. At some point the parser within Perl needs to be able to scan the original decrypted source. That means that at some stage fragments of the source will exist in a memory buf- fer. Also, with the introduction of the Perl Compiler backend modules, and the B::Deparse module in particular, using a Source Filter to hide source code is becoming an increasingly futile exercise. The best you can hope to achieve by decrypting your Perl source using a source filter is to make it unavailable to the casual user. Given that proviso, there are a number of things you can do to make life more difficult for the prospective cracker. 1. Strip the Perl binary to remove all symbols. 2. Build the decrypt extension using static linking. If the extension is provided as a dynamic module, there is nothing to stop someone from linking it at run time with a modified Perl binary. 3. Do not build Perl with "-DDEBUGGING". If you do then your source can be retrieved with the "-Dp" command line option. The sample filter contains logic to detect the "DEBUGGING" option. 4. Do not build Perl with C debugging support enabled. 5. Do not implement the decryption filter as a sub-process (like the cpp source filter). It is possible to peek into the pipe that con- nects to the sub-process. 6. Check that the Perl Compiler isn't being used. There is code in the BOOT: section of decrypt.xs that shows how to detect the presence of the Compiler. Make sure you include it in your module. Assuming you haven't taken any steps to spot when the compiler is in use and you have an encrypted Perl script called "myscript.pl", you can get access the source code inside it using the perl Compiler backend, like this perl -MO=Deparse myscript.pl Note that even if you have included the BOOT: test, it is still possible to use the Deparse module to get the source code for individ- ual subroutines. 7. Do not use the decrypt filter as-is. The algorithm used in this filter has been purposefully left simple. If you feel that the source filtering mechanism is not secure enough you could try using the unexec/undump method. See the Perl FAQ for further details. AUTHOR
Paul Marquess DATE
19th December 1995 perl v5.8.0 2003-01-27 decrypt(3)
All times are GMT -4. The time now is 08:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy