Useful OneLiners

# add first and penultimate columns
perl -lane 'print $F[0] + $F[-2]'

# just lines 15 to 17
perl -ne 'print if 15 .. 17' *.pod

# in-place edit of *.c files changing all foo to bar
perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c

# command-line that prints the first 50 lines (cheaply)
perl -pe 'exit if $. > 50' f1 f2 f3 ...

Lees meer

Perl “One-Liners”

Perl “One Liners” are -surprise surprise- little perl programs written on one line.

Here are a few simple examples :

Guess what this one does :-)

$ perl -e 'print "Hello";' -e 'print " World\n"'

DOS to Unix text convert

$ perl -i -pe 's/\r//g' file

Unix to DOS text convert

$ perl -i -pe 's/\n/\r\n/' file

‘Fun’ with columns:

$ echo a b c | perl -lane 'print $F[1]'
b
$ echo a b c | perl -lane 'print "@F[0..1]"'
a b
$ echo a b c | perl -lane 'print "@F[-2,-1]"'
b c

More one-liners will follow…

Cisco::Accounting 1.01 on CPAN

Also our perl module Cisco::Accounting is now available on CPAN.

This module parses and aggregates IP Accounting information from remote Cisco devices or from remote hosts running the IPCAD daemon.
Several other actions are possible like checking and changing the accounting setting on interfaces, clear ip accounting, etc.

The module summarizes all data that it has parsed and also keeps a history.

A front-end to this module is our CIPAT - Cisco IP Accounting Tool.

More information at our products page.

CIPAT 2.00 is now available

A new version of CIPAT is available for download. CIPAT is Cisco IP Accounting Tool which is a front-end for the Cisco::Accounting perl module.

CIPAT is still a platform independent perl based tool but it has many new features like support for Cisco devices as well as hosts which are running the IPCAD daemon.

Multiple output formats are now supported : HTML, CSV and XML.

A limitation on number of polls or time limit can be set to automatically stop CIPAT and generate reports.

Check out the product page to find out more about the new CIPAT and to see some screenshots.

Cisco::Version 0.02 available on CPAN

Our new Perl module Cisco::Version is also available on CPAN.

This module extracts as much data as possible from Cisco’s ’show version’ command. Many chassis types are support.

The following details can be extracted :

Read more …

Next Page →