« Convert TS files to DVD in Linux | Main | Adding SATA and other drivers to your windows installation cd »
Friday
06Mar2009

Bash Script Shortcuts

  I have been playing with some better ways to execute my scripts that I use alot.

  I have found a solution that works well for me and I hope you can make use of this too. I have a couple of dozen scripts that I use and about half of them I use all of the time. The first thing I did was made a bash script directory in my home folder. I named it 'bin'. Next I edited my home/<user>/.bashrc file and added these lines to the bottom of the file.

PATH=$PATH:~/bash 
export PATH

 

  What this does is includes the directory you put here in the list of executables.

  Next I closed any terminals I had open and when I reopened them I could just type in the name of the custom script and it will run without navigating to the directory where the script is stored. From now on, all you have to do is save your scripts to that directory, make them executable, and you are good to go. Some of my scripts had been kept on my data partition so it would get rather tedious to either type in the full path or navigate to the directory. I found this to be a big time saver.

  One of the things I find myself typing in the terminal alot is "sudo apt-get update" and "sudo apt-get upgrade".

  So I wrote a script to do it for me. The script looks like this


#! /bin/bash


sudo apt-get update && sudo apt-get upgrade

  I saved it to me home/drew/bin folder and named it updateme.

  Now when I am in the terminal I can just type 'updateme', and this issues two commands at once. Get the idea? This is great if you find yourself executing many commands throughout the day over and over again. You could just put all of your commands into one script and add it to your script directory. Give it a clever name and you are all set.

 

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.