Syntex erros (277 Views)
Posts: 28
Registered: ‎09-14-2011
Message 1 of 2 (277 Views)

Syntex erros

Hi All,


OS :- HPUS 11.11


I am using following script to compare dates. While executing , it throwing me following errors, since the script not execcuted fully, I am not sure, weather this is right way to compare dates. Also, not sure about the syntex part.


none> ./
./[7]: Syntax error at line 7 : `;' is not expected.
oradev3 oraadmin /home/oraadmin/test/dev_monitoring
none> cat -n
     1  #!/sbin/sh
     2  SID=qfin1
     3  . qa02
     4  typeset -i mHHMM=`date +%H%M`
     5  typeset -i mDD=$(date +%d)
     6  mDay=`date +%a`
     7  if [[ "${mDay}" = "Fri" && ${mHHMM} -gt 1604]]; then
     8  echo "Test succeded"
     9  fi


Acclaimed Contributor
Posts: 21,184
Registered: ‎07-06-2000
Message 2 of 2 (274 Views)

Re: Syntex erros



You need a space character before the closing square brackets on line-7.


if [[ "${mDay}" = "Fri" && ${mHHMM} -gt 1604 ]]; then

It's better form to avoid the archaic backtick syntax and use the modern Posix standard of $( ... ).  You did this line line-5.  This improves readability and helps eliminate typos that use a backtick instead of a single quote and vice versa.





The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.