I'm attempting to use grep in Perl with very little success.
What I would like to do in Perl is get the output of the following grep code:
This gives me a list of all the files in a directory that contain the pattern that was searched.
My attempts to do this in Perl have failed so far:
The above code is looking at the file names and not the contents of the files.
So my question is, how to can I use grep in perl to give me a list of the files that contain a certain pattern?
I am using a DEC ALPHA running Digital UNIX (formly DEC OSF/1) and ksh. I have a directory with hundreds of files that only share the extension .rpt. I would like to search that directory based on serial number and operation number and only files that meet both requirements to be printed out. I... (6 Replies)
Hello,
I'm trying to create a program in perl called myfind.pl;
To use the program:
(at the command line)$ program.pl keyword filename
note: the keyword is any word or regular expression
and it should display the result just like when you 'cat' the file name but with the keyword in... (2 Replies)
I have a situation where I need to search for multiple strings (error messages) such as 'aborted' 'file not found' etc in directory having logs. I have put all the error messages in a text file and using the command.
grep -f <textfile> <filetobegrepped>
I'm doing this thru a script where I... (5 Replies)
I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine.
Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now.
Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple... (1 Reply)
Hi All,
I have a issue in pulling some heavy records , I have my input file has 10,000 records which i need to compare with daily appended log files from (sep 1st 2009 to till date) . I tried to use grep fgrep and even sed , but the as time is factor for me , i cannot wait for 5 days to get the... (3 Replies)
I have a list of pattern in a file, I want each of these pattern been searched from 4 files. I was wondering this can be done in SED / AWK.
say my 4 files to be searched are
> cat f1
abc/x(12) 1
abc/x 3
cde 2
zzz 3
fdf 4
> cat f2
fdf 4
cde 3
abc 2... (6 Replies)
Hi,
I have code like:
Output it is comming as:
Rels: WM2
Rels: WG2
Rels: 5
- pre/prods.pl
Rels: 6
Rels: 7
Rels: 8
Rels: 10
Rels: Int
But i want only "Rels: 5" pattern Just above "- pre/prods.pl".
By... (7 Replies)
I am performing a regular check on UNIX servers which involves logging onto UNIX servers and using the grep command to check if a GID exists in the /etc/group directory
e.g. grep 12345 /etc/group
I have five to check on each server, is there anyway I can incorporate them into one command and... (2 Replies)
i have a file as below
grepfile.txt
----------------
RNTO command successful
No such file or directory
Authentication failed
if i seach individually for 'RNTO command successful' or 'No such file or directory' using grep -i as below, im gettting result.
grep -i 'No such file or... (5 Replies)
I am new to unix and I would like to search multiple log files to find earliest occurrence of a text.
Ex:
Say I have 10 logs file each ending with .log and I want to find the text “CustomeError” .
I want to find the which log file “CustomeError” comes first and lines which surround’s ... (4 Replies)
Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap(User Contributed Perl DocumentPerl::Critic::Policy::BuiltinFunctions::RequireBlockMap(3pm)NAME
Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap - Write "map { $_ =~ /$pattern/ } @list" instead of "map /$pattern/, @list".
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
The expression forms of "grep" and "map" are awkward and hard to read. Use the block forms instead.
@matches = grep /pattern/, @list; #not ok
@matches = grep { /pattern/ } @list; #ok
@mapped = map transform($_), @list; #not ok
@mapped = map { transform($_) } @list; #ok
CONFIGURATION
This Policy is not configurable except for the standard options.
SEE ALSO
Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval
Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-06-07 Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap(3pm)