2007年7月4日 星期三

shell script : execute with parameter

[will@localhost ShellScript]$ cat parameter.sh
#!/bin/sh

echo "The script name is ==> $0"

[ -n "$1" ] && echo "The 1st paramter is ==> $1" || exit 0
[ -n "$2" ] && echo "The 2nd paramter is ==> $2" || exit 0
[ -n "$3" ] && echo "The 3th paramter is ==> $3" || exit 0

echo "integer compare..."

[ "$1" -gt "$2" ] && echo $1" > "$2

[ "$1" -lt "$2" ] && echo $1" < "$2

[ "$1" -eq "$2" ] && echo $1" = "$2

echo "string compare..."

[ "$1" = "$2" ] && echo $1" = "$2

[ "$1" != "$2" ] && echo $1" != "$2

[will@localhost ShellScript]$

沒有留言:

網誌存檔

關於我自己