Computing.Net > Forums > Unix > comapring string with shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

comapring string with shell script

Reply to Message Icon

Name: mehul
Date: April 10, 2003 at 14:52:54 Pacific
OS: sun
CPU/Ram: sun
Comment:

Hi ,
I am trying to write the script , i want to run particular task only on tue and fri,
its not working what am i doing wrong can someone help...am i missing some bracket or i have to use -o (Boolean OR)...i have tried through
sanityrun_day=`date '+%a'`
if[ $sanityrun_day = 'Tue'-o $sanityrun_day = 'Fri' ]
then
echo "correct"
else
echo "no correct today is $sanityrun_day"
fi




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 10, 2003 at 15:30:32 Pacific
Reply:

Mehul:

On my solaris 7 box, running ksh, this works:

if [ $sanityrun_day = 'Tue' -o $sanityrun_day = 'Fri' ]
then
echo "correct"
else
echo "no correct today is $sanityrun_day"
fi

The shell is very particular: you need a space between the if and [ and a space between the end of the 'Tue' string and the
-o

Regards,


nails


0

Response Number 2
Name: Jimbo
Date: April 10, 2003 at 23:30:34 Pacific
Reply:

If you only want it to run on those days, why not do this with cron:

0 8 * * 2,5 /path/to/script

this example will run at 8am every tuesday and friday.

-jim


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


How to collect the files grab any two files!



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: comapring string with shell script

help with shell script www.computing.net/answers/unix/help-with-shell-script/7840.html

Help with shell scripts www.computing.net/answers/unix/help-with-shell-scripts/4729.html

backup a file with SHELL SCRIPT www.computing.net/answers/unix/backup-a-file-with-shell-script/4522.html