10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to make a script that will list all directories under a selection as well as the number of files in each.
I cannot get it to work under a symbolic link.
The file structure is:
XXX_20131127_001
dir01 (sym link)
2404x912
file.0000.xxx to
... (10 Replies)
Discussion started by: scribling
10 Replies
2. UNIX for Advanced & Expert Users
Hi,
I'm quite new to ksh scripting, can someone help me with this.
Requirements:
I need to create a script that list the files from a user input date range.
e. g. format of file:
*c1*log.2012-12-22-14-00*
*c1*log.2012-12-22-14-00*
*c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies
3. Programming
for example, I have a text file in random content inside, maybe something like this.
234234
54654
123134
467456
24234234
7867867
23424
568567if I run this command
cat "filename.txt" | sort -n | grep "^467456$" -A 1 -B 1the result is
234234
467456
568567is it possible to do this command... (2 Replies)
Discussion started by: 14th
2 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I am trying to do the following:
grep -l <pattern> <files to be searched for>
In <files to be searched for> , all files should of some specific date like "Apr 8" not all files in current directory. I just to search within files Apr 8 files so that it won't search in entire list of... (2 Replies)
Discussion started by: apjneeraj
2 Replies
5. Shell Programming and Scripting
Hi all,
I am using the below script which display the files in the folder with the date range we specify. I want to add extra functionality that,
The listing files should be zipped using gzip. I tried to add exec gzip at the last line but it is not working.
Suggestions please.
... (2 Replies)
Discussion started by: nokiak810
2 Replies
6. Shell Programming and Scripting
Hey everyone,
I'm trying get a list of files using but also append some data located inside the file.
The log files contain two strings that I am trying to extract. These strings are surrounded by tags.
Here is a sample log file:
... (2 Replies)
Discussion started by: ToeLint
2 Replies
7. Shell Programming and Scripting
Hi All,
Can we grep one word in two file at same time. i.e using one command only. for ex
egrep -i "word" file1 file2
is it possible? (1 Reply)
Discussion started by: sam25
1 Replies
8. Shell Programming and Scripting
Hi,
I have 10 folders like a1,a2,a3...a10
each folder having 100 files.
how to grep a word from all the files in all folders at a time? (8 Replies)
Discussion started by: suresh3566
8 Replies
9. Shell Programming and Scripting
Hi I have find some account numbers from .gz files.
There thousands of .gz files, also i am unable to grep .gz / .z files.
I want to find file names & and those lines from list.
Could you pls tell me / give me any syntax for finding word from ,gz files using grep?
Thanks in advance (8 Replies)
Discussion started by: udaya_subbu
8 Replies
10. Shell Programming and Scripting
hi,
how to list the files which has been created or accessed before 6 months
thanks (1 Reply)
Discussion started by: useless79
1 Replies
POE::Filter::Stackable(3pm) User Contributed Perl Documentation POE::Filter::Stackable(3pm)
NAME
POE::Filter::Stackable - combine multiple POE::Filter objects
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::Stackable combines multiple filters together in such a way that they appear to be a single filter. All the usual POE::Filter
methods work, but data is secretly passed through the stacked filters before it is returned. POE::Wheel objects and stand-alone programs
need no modifications to work with a filter stack.
In the "SYNOPSIS", POE::Filter::Line and POE::Filter::Grep are combined into one filter that only returns a particular kind of line. This
can be more efficient than filtering lines in application space, as fewer events may need to be dispatched and handled.
Internally, filters are stored in an array.
Data added by get_one_start() will flow through the filter array in increasing index order. Filter #0 will have first crack at it,
followed by filter #1 and so. The get_one() call will return an item after it has passed through the last filter.
put() passes data through the filters in descending index order. Data will go through the filter with the highest index first, and put()
will return the results after data has passed through filter #0.
PUBLIC FILTER METHODS
In addition to the usual POE::Filter methods, POE::Filter::Stackable also supports the following.
new
By default, new() creates an empty filter stack that behaves like POE::Filter::Stream. It may be given optional parameters to initialize
the stack with an array of filters.
my $sudo_lines = POE::Filter::Stackable->new(
Filters => [
POE::Filter::Line->new(),
POE::Filter::Grep->new(
Put => sub { 1 }, # put all items
Get => sub { shift() =~ /sudo[d+]/i },
),
]
);
pop
Behaves like Perl's built-in pop() for the filter stack. The highest-indexed filter is removed from the stack and returned. Any data
remaining in the filter's input buffer is lost, but an application may always call "get_pending" in POE::Filter on the returned filter.
my $last_filter = $stackable->pop();
my $last_buffer = $last_filter->get_pending();
shift
Behaves like Perl's built-in shift() for the filter stack. The 0th filter is removed from the stack and returned. Any data remaining in
the filter's input buffer is passed to the new head of the stack, or it is lost if the stack becomes empty. An application may also call
"get_pending" in POE::Filter on the returned filter to examine the filter's input buffer.
my $first_filter = $stackable->shift();
my $first_buffer = $first_filter->get_pending();
push FILTER[, FILTER]
push() adds one or more new FILTERs to the end of the stack. The newly pushed FILTERs will process input last, and they will handle output
first.
# Reverse data read through the stack.
# rot13 encode data sent through the stack.
$stackable->push(
POE::Filter::Map->(
Get => sub { return scalar reverse shift() },
Put => sub { local $_ = shift(); tr[a-zA-Z][n-za-mN-ZA-M]; $_ },
)
);
unshift FILTER[, FILTER]
unshift() adds one or more new FILTERs to the beginning of the stack. The newly unshifted FILTERs will process input first, and they will
handle output last.
filters
filters() returns a list of the filters inside the Stackable filter, in the stack's native order.
Calling "<$filter_stack-"filters()>> in the "SYNOPSIS" would return a list of two filter objects:
POE::Filter::Line=ARRAY(0x8b5ee0)
POE::Filter::Grep=ARRAY(0x8b5f7c)
filter_types
filter_types() returns a list of class names for each filter in the stack, in the stack's native order.
Calling "<$filter_stack-"filter_types()>> in the "SYNOPSIS" would return a list of two class names:
POE::FIlter::Line
POE::Filter::Grep
It could easily be replaced by:
my @filter_types = map { ref } $filter_stack->filters;
SEE ALSO
POE::Filter for more information about filters in general.
Specific filters, amongst which are: POE::Filter::Block, POE::Filter::Grep, POE::Filter::HTTPD, POE::Filter::Line, POE::Filter::Map,
POE::Filter::RecordBlock, POE::Filter::Reference, POE::Filter::Stream
BUGS
None currently known.
AUTHORS & COPYRIGHTS
The Stackable filter was contributed by Dieter Pearcey. Documentation 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::Stackable(3pm)