I've been trying to filter a file which has several repetitions of lines which looks as follows:
Each line has different values in them. I want grep or awk or sed to treat everything within the (' and >>) as one line and then filter for a single word, for example jamie.
Any ideas how to do this?
PS:
I had tried a solution based on the following awk '/START:/{if (NR!=1)print "";next}{print $0}END{print "";}. However, the output still seems to be in separate lines...
I above gives me a solution as follows:
Is there an easy way to merge lines not separated by a blank line into a single line?
Thanks.
Last edited by jamie_123; 01-29-2016 at 10:50 AM..
Hi,
I am trying to set up a cron job for every Friday at 6:00 p.m. and got an error:
"/var/tmp/aaaa29638" 1 line, 73 characters
00 18 00 0 5 /app/test/backup.ksh
crontab: error on previous line; number out of bounds.
Any ideas?
Thanks! (1 Reply)
After allocating memory for some variables, segfault is often to happen, due to the same reason: Address 0x1cd00000103 out of bounds
It is welcome to recommend some treatments. Thanks
e.g.
is_done = 0x1cd00000103 <Address 0x1cd00000103 out of bounds>,
hood = 0x23c00000247,
c =... (11 Replies)
Hello,
I looking to use grep to return a string with exactly n matches.
I'm building off this:
ls -aLl /bin | grep '^.\{9\}x' | tr -s ' '
-rwxr-xr-x 1 root root 632816 Nov 25 2008 vi
-rwxr-xr-x 1 root root 632816 Nov 25 2008 view
-rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Hi,
I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat.
My OS is:
SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
I wish to traverse all files and folders under a given directory say "/tmp/configuration" and for all ip address mentioned therein.
I tried find ./ -type f | xargs grep "*.*.*.*" but it does not populated the correct results.
Can you please suggest. (1 Reply)
Command 1:
$script | grep 'Write to ECC( SSID=MARGIN)'
Command 2:
$script | grep 'is not greater than existing logical processing'
The above commands run my script and search the mentioned strings but I do not want to run my script twice. It is increasing run time.
Can someone tell me... (3 Replies)
What exactly is the -Warray-bounds option to the GCC compiler supposed to warn about?
the man page states:
~ g++ --version
g++ (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
Copyright (C) 2017 Free Software Foundation, Inc.Thank you. (14 Replies)
Discussion started by: milhan
14 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)