i edited the script and the name part works well...Really happy..Thanks!!!
But the date part still got error..
#!/bin/sh
dir=/home/input/test.log
msg=`tail -1 $dir`
type=Report
name=${msg%% is Failed *}
name=${name#ERROR: }
status=Failed
if [ ${#name} -eq ${#msg} ]
then
name=${msg%% successfully *}
status=Success
datetime=${msg##*ran on }
fi
datetime=${msg##* on }
datetime=${datetime%% SST *}
time=${datetime##* }
#date=${date -d "$date" "+%d %b %Y"}
#date=date -d "$datetime" "+%d %b %Y"
date=$(date -d "$date" "+%d %b %Y")
logdate=${date -d "$logdate" "+%d %b %Y"}
#date=${datetime% *}
#date=date -d "$datetime" "+%d %b %Y"
echo "$msg"
#echo "$datetime"
#echo "$name"
#echo "$type"
#echo "$status"
#echo "$time"
echo "$date"
echo "$logdate"
when i run the script, i got this message:
date: illegal option -- d
Usage: date [-u] [+format]
date [-u] [mmddhhmm[[cc]yy]]
date [-a [-]sss.fff]
./test2.sh[28]: logdate=${date -d "$logdate" "+%d %b %Y"}: The specified substitution is not valid for this command.
How could i solve this??