Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-06-2004, 01:35 PM   #1
LQ Newbie
Registered: Nov 2003
Location: Broome County, NY
Distribution: SUSE 10 SP 2
Posts: 20

Rep: Reputation: 0
bash month variable

I would like to execute some bash script ten months during the year, just not July or August. So, I tried to capture the month number and would compare latter, but it doesn't work.

For example:

declare -i mon='date +%m'
echo $mon

Produces an error.
-bash: declare: date +%m: syntax error: operand expected (error token is "%m")

Oh, there must be a better way. Thanks in advance....
Old 12-06-2004, 01:41 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Just use this (note the backticks):
mon=`date +%m`

If you are running from cron then you can also specify the months to run in field 4:
man crontab


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
transform month number to month name in php ALInux Programming 1 11-09-2005 10:45 AM
bash, how to get variable name from variable Duudson Programming 6 01-06-2005 04:38 PM
Variable with bash pinkysioux Programming 6 04-15-2004 08:46 PM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 04:03 PM
getting last locale's abbreviated month name through bash scripting markus1982 Programming 2 05-10-2003 08:31 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:58 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration