Skip to content

Instantly share code, notes, and snippets.

@miend miend/logosfunc.bash
Created Sep 17, 2012

Embed
What would you like to do?
Logos's handy functions.
function ipprint(){ LST=$@ ; ( [ -e "$LST" ] && cat $LST ; [ ! -e "$LST" ] && for i in $LST ; do echo $i ; done ) | while read host ; do echo -en "$host:\t$(dig +short $host.fqdn.com )\n" ; done ; }
# Takes a string of arbitrary length of servers on your intranet and lists them colon-and-tab delimited next to their IP addresses
function ksmtop(){ (cd /sys/kernel/mm/ksm/ ; while true ; do date ; for i in `ls` ; do printf "%-20s %-20s\n" $i `cat $i` ; done ; sleep 2 ; clear ; done) ; }
# Does top-like output for a server's KSM metrics (RAM deduplication in KVM)
function inpath(){ for item in $@ ; do echo $PATH | awk -F':' '{ for (i=2 ; i<=NF ; i++) print $i ; }' | while read line ; do ls $line | grep $item ; done ; done ; }
# Takes a partial string and reports what commands are currently in your $PATH that are successful matches to it
function du_by_size(){ du -ks * | sort -nr | cut -f2 | xargs du -hs ; }
# Prints in human readable format the disk usage sizes from largest to smallest of your current working directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.