Using Perl instead of awk or sed

Unix — Dillon @ 11:29 am

You want to use Perl to process things on the command line but you don’t want to write/save a file. You want to replace sed with something more clunky. :)


[user@server tmp]$ ls / | perl -e 'while (){ print $_; }'
bin
boot
dev
etc
home
initrd
lib
lost+found
misc
mnt
opt
proc
root
sbin
tmp
usr
var
[user@server tmp]$ ls / | perl -e 'while (){ print "/" . $_; }'
/bin
/boot
/dev
/etc
/home
/initrd
/lib
/lost+found
/misc
/mnt
/opt
/proc
/root
/sbin
/tmp
/usr
/var

Finding busy disks with iostat and awk

Unix — Dillon @ 2:40 pm

So you want to find busy disks in solaris? Maybe you want a quick iostat summary? Need an easier way to find slow disks? Getting percent busy info from iostat is easy with awk. Usually any disk with %busy greater than 0 (some people prefer >= 2) is a sign of a slow disk.


iostat -xcn|awk '$10 > 0{ print $10"%" " - " $11 }'

Or perhaps you want to see how many disks are considered ‘slow’ in your system:


echo `iostat -xcn|awk '$10 > 0{ print $10"%" " - " $11 }'|wc -l` out of `iostat -xcn|wc -l`

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 SQUARISM | powered by WordPress with Barecity