Monday, July 20, 2009

Assignment 5 - Another Hint

Here's a sample script which changes a directory:


#!/bin/bash
if [ "$#" -eq "0" ]
then
echo "usage: cdTest directory_name"
else
newDir=$1
cd $newDir
fi

Note: Watch the spaces! Unlike other programming langauges, shell programming is a stickler for proper formatting.

Call this script 'cdTest' and run it like:
. cdTest
-or-
source cdTest

and see what it does.

If you guys need extra time, email me, and I'll be willing to extend the deadline. Please note, though, if I extend the deadline, we'll be adding a couple 'extra' features to the assignment.

No comments:

Post a Comment