Cowsay as much as possible


CowsayIfPossible()
{
  if [ -z "${1}" ]; then
    CowsayIfPossible "Supply some text!";
    return;
  fi
  if which cowsay >> /dev/null; then
    cowsay "${1}"
    echo =======================================
  else
    echo "${1}"
  fi
}

Cowsay is win.  EEEPPIIIICCC  WIIIIN.

This BASH script snippet allows the unashamed use of cowsay within bash scripts without fear that it isn’t installed.  World peace?  That’d be nice, but for now cowsay moooooo!

sudo aptitude install cowsay

New and improved! The previous post on one line!

This following bash code outputs the puzzlebot facebook email from my previous post with no extra output. This is one of those “just for fun things” that non-CS people don’t understand.

echo -e "#include <stdio.h>\nint main(int argc, char ** args){printf(\"%d@facebook.com\\\n\", 0xFACEB00C>>2); return 0;}" > fbmail.c; g++ fbmail.c -o fbmail; ./fbmail; rm fbmail.c fbmail