Monday, April 18, 2011

Bash_Prog using input argument from Command line

[q.yang@localhost Sandbox]$ cat SetDefault.sh
#!/bin/bash
# 19/APR/2011
# Author Quentin YANG
# Copy certain version app to default app.

# if no input argument, string is null or not '-z'
if [ -z "$1" ]
then
echo "please type CommsModule version you want make it default.e.g.'. SetDefault.sh 012'"
return
#exit
fi

VerRange=$1

NAME='GsnCommsTask'_$1

echo "You've chosen '$NAME' as default CommsModule App"

#cd $JIST_HOME

if [ -f "$NAME" ]
then
cp -p $NAME GsnCommsTask
echo "All files under this directory:"
ls -al
else
echo "Error: '$NAME' not found!"
fi

No comments: