Tuesday, June 17, 2014

Useful 1 liner perl script(s)

I'll be updating this article for every time I use a one-liner perl code I need to use at work.

1.  perl -n -e 'chomp;print $_ . " "';

If I need to concatenate input with spaces and I need to display it.

#rpm -qa|grep rpm|perl -n -e 'chomp;print $_ . " "';
rpm-libs-4.8.0-37.el6.x86_64 rpm-4.8.0-37.el6.x86_64 rpm-python-4.8.0-37.el6.x86_64

#rpm -qa|grep perl|perl -n -e 'chomp;print $_ . " "' | xargs echo "yum install";
yum install perl-Pod-Escapes-1.04-136.el6.x86_64 perl-libs-5.10.1-136.el6.x86_64 perl-Module-Pluggable-3.90-136.el6.x86_64 perl-DBI-1.609-4.el6.x86_64 perl-Net-LibIDN-0.12-3.el6.x86_64 perl-Net-SSLeay-1.35-9.el6.x86_64 perl-Time-HiRes-1.9721-136.el6.x86_64 perl-Pod-Simple-3.13-136.el6.x86_64 perl-version-0.77-136.el6.x86_64 perl-5.10.1-136.el6.x86_64 perl-DBD-MySQL-4.013-3.el6.x86_64 perl-IO-Socket-SSL-1.31-2.el6.noarch

No comments: