As is often the case with a little bit of jiggery pokery there is a pseudo-back-door.
The storage device can be your friend although it will slow things down with the disk thrashing and huge numbers.
NOTE: This uses 'dash' which means it is fully POSIX compliant.
Results OSX 10.14.3, default terminal.
This User Gave Thanks to wisecracker For This Post:
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Hi,
I have a file (details.txt) with 3 rows of variables ie...
name postcode age
john D fr25dd 25
mark W ab122aa 22
phil C cd343bb 33
What I want to do is read down the list with a loop and add each field into a one line piece of text...
So I have a file (test1) which reads;... (3 Replies)
I am writing a shell script using the korn shell. It seems that I am only
able to use local variables within a while loop that is reading a file.
(I can't access a variable outside a previously used while loop.) It's been
a while since I wrote shell scripts. Here is a sample
cat file.txt... (4 Replies)
Hi Friends ,
Sorry if this is a repeated question ,
The input file contains 5 lines , so the the values of the variables i and count should b
i=5;
count=15
but the variables are not updating , the value of variables showing i=0 and count =0 only.:mad:
can any1 help me please. (11 Replies)
Hello
I am having issues with a script I'm working on developing on a Solaris machine.
The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today.
Here is my while loop:
last $user | grep -v 'sshd'... (7 Replies)
Hi All,
I've been researching this problem and I am pretty sure that the issue is related to the while loop and the piping. There are plenty of other threads about this issue that recommend removing the pipe and using redirection. However, I haven't been able to get it working using the ssh and... (1 Reply)
Hi,
I have a loop running until a variable L that is read previously in the full script. I'd like to grep some information in an input file at a line that contains the value of the loop parameter $i.
I've tried to use grep, but the problem is nothing is written in the FILE files. It seems grep... (5 Replies)
Hello! Before you "bash" me with
- Not another post of this kind
Please read on and you will understand my problem...
I am using the below to extract a sum of the diskIO on a Solaris server.
#!/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin; export PATH
TEMP1="/tmp/raw-sar-output.txt$$"... (3 Replies)
Dear mentors, I just need little explanation regarding for loop to give input to awk script
for file in `ls *.txt |sort -t"_" -k2n,2`; do
awk script $file
done
which sorts file in order, and will input one after another file in order to awk script
suppose if I have to input 2 or... (4 Replies)
Hi,
I'm a Delphi developer new to linux, new to this forums and new to BASH programming and got a new task in my work: maintaining an existing set of BASH scripts. First thing I want to do is making the code more reliable as in my opinion it's really bad written. So here's the quest:
I'm... (6 Replies)
Discussion started by: rse
6 Replies
LEARN ABOUT DEBIAN
poe::filter::map
POE::Filter::Map(3pm) User Contributed Perl Documentation POE::Filter::Map(3pm)NAME
POE::Filter::Map - transform input and/or output within a filter stack
SYNOPSIS
#!perl
use POE qw(
Wheel::FollowTail
Filter::Line Filter::Map Filter::Stackable
);
POE::Session->create(
inline_states => {
_start => sub {
my $parse_input_as_lines = POE::Filter::Line->new();
my $redact_some_lines = POE::Filter::Map->new(
Code => sub {
my $input = shift;
$input = "[REDACTED]" unless $input =~ /sudo[d+]/i;
return $input;
},
);
my $filter_stack = POE::Filter::Stackable->new(
Filters => [
$parse_input_as_lines, # first on get, last on put
$redact_some_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::Map transforms data inside the filter stack. It may be used to transform input, output, or both depending on how it is
constructed. This filter is named and modeled after Perl's built-in map() function.
POE::Filter::Map 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 redact all entries that don't pertain to a sudo process.
PUBLIC FILTER METHODS
In addition to the usual POE::Filter methods, POE::Filter::Map also supports the following.
new
new() constructs a new POE::Filter::Map 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 transformed versions of their sole parameters. 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.
# Decrypt rot13.
sub decrypt_rot13 {
my $encrypted = shift;
$encrypted =~ tr[a-zA-Z][n-za-mN-ZA-M];
return $encrypted;
}
# Encrypt rot13.
sub encrypt_rot13 {
my $plaintext = shift;
$plaintext =~ tr[a-zA-Z][n-za-mN-ZA-M];
return $plaintext;
}
# Decrypt rot13 on input, and encrypt it on output.
my $rot13_transcrypter = POE::Filter::Map->new(
Get => &decrypt_rot13,
Put => &encrypt_rot13,
);
Rot13 is symmetric, so the above example can be simplified to use a single Code function.
my $rot13_transcrypter = POE::Filter::Map->new(
Code => sub {
local $_ = shift;
tr[a-zA-Z][n-za-mN-ZA-M];
return $_;
}
);
modify
modify() changes a POE::Filter::Map object's behavior at run-time. It accepts the same parameters as new(), and it replaces the existing
transforms with new ones.
# Switch to "reverse" encryption for testing.
$rot13_transcrypter->modify(
Code => sub { return scalar reverse shift }
);
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 Map 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::Map(3pm)