Sh

From Secure Computing Wiki
Revision as of 08:39, 23 May 2008 by 74.95.66.25 (Talk) (get name of host directory for a script)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To get the name of the directory in which a script resides, the following code example will work:

#!/bin/sh
echo "I live in `dirname $0`"

Simply put this in test.sh within your home directory, and do the following to see:

cd /
sh ~/test.sh