Check the memory usage of your favourite application in style. Grep the output of ps!
function ram() { ps auxf | grep $1 | grep -v grep | awk '{sum=sum+$6}; END {print sum+1023/1024}' ; }
Append the time and date to the start of your files.
function datestamp()
{
for x in $@; do
if [ -e $x ]; then
mv $x $(date +'%F')-$x
else
echo "$x? File doesn't exist, fool."
fi
done
}
Install, remove, autoremove and purge. Now renamed Loadry, unloadry, laundry and nuke, respectively.
function loadry () {
if [ $(whoami) != "root" ] ; then
sudo apt-get install $@
else
apt-get install $@
fi
}
function unloadry() {
if [ $(whoami) != "root" ] ; then
sudo apt-get remove $@
else
apt-get remove $@
fi
}
function laundry() {
if [ $(whoami) != "root" ] ; then
sudo apt-get autoremove $@
else
apt-get autoremove $@
fi
}
function nuke() {
if [ $(whoami) != "root" ] ; then
sudo apt-get autoremove --purge $@
else
apt-get autoremove --purge $@
fi
}
For anybody who followed the Futurama tutorial, here’s a little something extra, just for you.
function woots() { #!/bin/bash
cows=(/usr/share/cowsay/cows/*.cow)
num=${#cows[@]}
((num=RANDOM%num))
randcow=`echo ${cows[$num]}`
if [[ $randcow = "/usr/share/cowsay/cows/leela.cow" ]] || [[ $randcow = "/usr/share/cowsay/cows/fry.cow" ]] || [[ $randcow = "/usr/share/cowsay/cows/bender.cow" ]];
then futurama;
else
phrase=`fortune -a`
cowsay -f $randcow $phrase;
fi;
}
Ah shucks, maybe someone will find this nonsense useful some day.
0 Responses to “Bash aliases: check memory usage, package management, and more!”