Creating Custom Linux Commands

This is a guest post by Taylor Douglass

The other day I ran across a script at shell-fu that generates a random quote from their website (here). I thought it would be useful to make this a command that I could execute at any terminal at anytime. Let’s get started.

First of all you are going to need links. If you don’t have links or are not sure if you do or not, fire up a terminal and type the following:

# sudo apt-get install links

Next navigate to your /bin folder and create the file

# sudo touch shell-fu

Make the file readable and executable

# sudo chmod +rx shell-fu

Now edit the file and add the code for retrieving the shell-fu quote (I use nano for this)

# sudo nano shell-fu
# links -dump "http://www.shell-fu.org/lister.php?random" | grep -A 100 -- ----
^O (writes the file from nano)
^X (exits nano)

You now have a custom command named “shell-fu” that you can type from anywhere and retrieve a random shell-fu quote.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>