Posts Tagged ‘apt-get

06
Jul
09

Bash aliases: check memory usage, package management, and more!

Check the memory usage of your favourite application in style. Grep the output of ps!

Code:
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.

Code:
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.

Code:
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.

Code:
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.

Advertisements



January 2019
M T W T F S S
« Aug    
 123456
78910111213
14151617181920
21222324252627
28293031  

Stuff goes here

Hijack this blog

You want to use something from this blag? What the hell is wrong with you? Do you want to fail at life? If you reuse the crap I post here, people will say, "Wow, I never knew anybody could be so ignorant!" Then they will go and find a weapon to beat you with. That's right. There's your god-damned copyright notice. You really care about that shit? Fine. Take it, copy it, pretend it's your own work. Do whatever the hell you want with it, I don't care.

Blog Stats

  • 14,061 people hate me.
Advertisements