![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A challenging problem involving symbolic links. | ibloom | High Level Programming | 2 | 03-24-2008 10:07 AM |
| (+ sign) Unexpected arithmetic expr script interpretation | Birdi6022 | UNIX for Dummies Questions & Answers | 9 | 08-11-2007 10:28 AM |
| problem in arithmetic operations | ithirak17 | Shell Programming and Scripting | 3 | 02-06-2007 06:46 AM |
| arithmetic problem | inquirer | UNIX for Dummies Questions & Answers | 2 | 02-20-2002 02:27 AM |
| Unix + oracle doubt....involving shell script | mexx_freedom | UNIX for Dummies Questions & Answers | 2 | 08-02-2001 09:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem in script involving month arithmetic
advance happy new year to all,
i am having a script.The purpose of the scripts is as follows.If the current month is march,june,september or december ,inc_flg should be set to '1' otherwise inc_flg should be set to '2' month= date +"%m" if [ "$month" -eq 3 ] || [ "$month" -eq 6 ] || [ "$month" -eq 9 ] || [ "$month" -eq 12 ] ; then inc_flg = 1 else inc_flg = 2 fi But i am getting inc_flg =2 always.please help me to solve this issue.Is there anyother way to write a script???please help me.thanks in advance regards, rajarp |
|
||||
|
u can directly subtituite command in loop u can do this it works
![]() #!/bin/sh if [ `date +"%m"` -eq 3 ] | [ `date +"%m"` -eq 6 ] | [ `date +"%m"` -eq 9 ] | [ `date +"%m"` -eq 12 ] ; then echo "inc_flg = 1" else echo "inc_flg = 2" fi |
|
||||
|
Quote:
Code:
...
case $month in
3|6|9|12) echo "yes";;
*) echo "no";;
esac
..
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|