This gives you the line chopped up into fields in a file. Play with it until you get what you want.
Just had a little play around with what you suggested, and found that the following works:
The above returns only the record i require, and does not require a new file been created etc. I had played about with awk -F , '$4 == 2' but that didnt work, however using the "~" and "/" does work.
Thankyou!
Last edited by Don Cragun; 01-22-2016 at 11:19 PM..
Reason: Add CODE and ICODE tags again.
ppl,
this is my "file" with fields
orderno orderdate orderdesc telno street city
1 01/04/2006 abc 123 100 tampa
2 01/04/2006 abc 123 100 tampa
3 01/04/2006 abc 123 100 tampa
4 01/04/2006 abc ... (2 Replies)
Dear All
I want to search string "1000" from input file and if it found i want remove line that contain 1000 and also remove 3 line above it and 2 line below it.
INPUT FILE:
BHAT-D 2
aaa
ID CODE GS UPDATE MODE LANG MCO MCL NUMPAGES
50 ... (7 Replies)
I have a file on UNIX system from where I want to grep the list of all users associated to the particular repository.If the user's list is in single line then I fetch all list but if it is in two separate lines it doesn't.I use the below command
a=KESTREL-DEV;b=users;cat access_file|grep... (1 Reply)
I'd like to copy strings from a log file and put them into a CSV.
The strings could be on different line numbers, depending on size of log.
Example Log File:
File = foo.bat
Date = 11/11/11
User = Foo Bar
Size = 1024
...
CSV should look like:
"foo.bat","11/11/11","Foo Bar","1024" (7 Replies)
Hi,
I have a file with "n" number of lines. I need to get rid of a specific line having a specific string from the file. I tried some possibilities but not successful.
For ex: in a file named "test"
hope should be removed along with the line.
... (8 Replies)
Hello,
I know there are many questions and replies regarding grep command.
What I would like to do is a bit different.
File A:
hello world welcome to my page
this is my test site
how are you
I am fine, thank you
where have you been
I was in hospital
really hope you are fine now
Thanks,... (10 Replies)
Hello,
I have two files. All urls are space seperated.
source
http://xx.yy.zz http://df.ss.sd.xz http://09.09.090.01
http://11.22.33 http://canada.xx.yy http://01.02.03.04
http://33.44.55 http://98.87.76.65 http://russia.xx.zz
http://aa.tt.xx.zz http://1w.2e.3r.4t http://china.rr.tt
... (4 Replies)
Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried:
grep -lr "this string" *
but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies
LEARN ABOUT DEBIAN
poe::filter::grep
POE::Filter::Grep(3pm) User Contributed Perl Documentation POE::Filter::Grep(3pm)NAME
POE::Filter::Grep - select or remove items based on simple rules
SYNOPSIS
#!perl
use POE qw(
Wheel::FollowTail
Filter::Line Filter::Grep Filter::Stackable
);
POE::Session->create(
inline_states => {
_start => sub {
my $parse_input_as_lines = POE::Filter::Line->new();
my $select_sudo_log_lines = POE::Filter::Grep->new(
Put => sub { 1 },
Get => sub {
my $input = shift;
return $input =~ /sudo[d+]/i;
},
);
my $filter_stack = POE::Filter::Stackable->new(
Filters => [
$parse_input_as_lines, # first on get, last on put
$select_sudo_log_lines, # first on put, last on get
]
);
$_[HEAP]{tailor} = POE::Wheel::FollowTail->new(
Filename => "/var/log/system.log",
InputEvent => "got_log_line",
Filter => $filter_stack,
);
},
got_log_line => sub {
print "Log: $_[ARG0]
";
}
}
);
POE::Kernel->run();
exit;
DESCRIPTION
POE::Filter::Grep selects or removes items based on simple tests. It may be used to filter input, output, or both. This filter is named
and modeled after Perl's built-in grep() function.
POE::Filter::Grep is designed to be combined with other filters through POE::Filter::Stackable. In the "SYNOPSIS" example, a filter stack
is created to parse logs as lines and remove all entries that don't pertain to a sudo process. (Or if your glass is half full, the stack
only selects entries that DO mention sudo.)
PUBLIC FILTER METHODS
In addition to the usual POE::Filter methods, POE::Filter::Grep also supports the following.
new
new() constructs a new POE::Filter::Grep object. It must either be called with a single Code parameter, or both a Put and a Get parameter.
The values for Code, Put, and Get are code references that, when invoked, return true to select an item or false to reject it. A Code
function will be used for both input and output, while Get and Put functions allow input and output to be filtered in different ways. The
item in question will be passed as the function's sole parameter.
sub reject_bidoofs {
my $pokemon = shift;
return 1 if $pokemon ne "bidoof";
return;
}
my $gotta_catch_nearly_all = POE::Filter::Grep->new(
Code => &reject_bidoofs,
);
Enforce read-only behavior:
my $read_only = POE::Filter::Grep->new(
Get => sub { 1 },
Put => sub { 0 },
);
modify
modify() changes a POE::Filter::Grep object's behavior at run-time. It accepts the same parameters as new(), and it replaces the existing
tests with new ones.
# Don't give away our Dialgas.
$gotta_catch_nearly_all->modify(
Get => sub { 1 },
Put => sub { return shift() ne "dialga" },
);
SEE ALSO
POE::Filter for more information about filters in general.
POE::Filter::Stackable for more details on stacking filters.
BUGS
None known.
AUTHORS & COPYRIGHTS
The Grep filter was contributed by Dieter Pearcey. Documentation is provided by Rocco Caputo.
Please see the POE manpage for more information about authors and contributors.
perl v5.14.2 2012-05-15 POE::Filter::Grep(3pm)