Friday 15 August 2008

Shell script argument check and directory check

With this part you can check arguments are supplied and give usage information.
if [ $# -ne 2 ]
then
echo 1>&2 Usage: $0 firstdatafile lastdatafile
exit 127
fi

Create if directory does not exist
DESTDIR=dirname
if ! test -d "$DESTDIR"
then mkdir -p $DESTDIR
fi

No comments: