![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error in if statement | capri_drm | Linux | 16 | 05-14-2008 02:00 PM |
| Error with if statement..Please help | jisha | Shell Programming and Scripting | 1 | 01-16-2008 07:13 AM |
| parsing error in if statement | rakeshou | Shell Programming and Scripting | 2 | 09-25-2007 10:46 AM |
| For loop statement - catch error | lumdev | Shell Programming and Scripting | 4 | 09-20-2007 07:50 AM |
| tar error statement | legato | UNIX for Dummies Questions & Answers | 3 | 03-29-2005 09:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Snytax error on If Statement--help
year=`date '+%Y'`
month=`date '+%m'` day=`date '+%d'` day=`expr $day - 1` case $month in 1 | 3 | 5 | 7 | 8 | 10 | 12);; if($day =7 ); then $day=6 fi 4 | 6 | 9 | 11);; if [ $day = 0 ] ; then $day=31 fi 2);; if [ $day = 0 ] ; then if [ `expr $year % 4` -eq 0]; then $day = 28 else $day = 29 fi fi *) echo error: too many arguments 1>&2 ;; esac DATE=$year$month$day cp $HOME/*$DATE*.log $HOME/QVGLog cd $HOME/QVGLog gzip * the error message is ./call: line 9: syntax error near unexpected token `(' ./call: line 9: `if($day =7 ); then' Pls help, i've checked the syntax for if else statement on web, but cant fix it. ![]() |
|
||||
|
Ok i've fixed
year=`date '+%Y'` month=`date '+%m'` day=`date '+%d'` day=`expr $day - 1` case $month in 1 | 3 | 5 | 7 | 8 | 10 | 12) if [ $day = 7 ] then $day=6 fi ;; 4 | 6 | 9 | 11) if [ $day = 0 ] then $day=31 fi ;; 2) if [ $day = 0 ] then if [ `expr $year % 4` -eq 0] then $day = 28 else $day = 29 fi fi ;; *) echo error: Case Statement Not Run ;; esac DATE=$year$month$day cp $HOME/*$DATE*log $HOME/QVGLog cd $HOME/QVGLog gzip * now the problem is the case statement failed, the message is error: Case Statement Not Run cp: cannot stat `/sgxde/sgxaspecs7/*2008057*log': No such file or directory gzip: *: No such file or directory ![]() |
|
||||
|
please post your script with the code tags to preserve indentation. This makes it much easier to read.
the case statement did not fail. You just hit the default condition. If you don't want the code after to execute then add an exit. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|