LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 12-06-2004, 01:35 PM   #1
johniccp
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:

#!/bin/sh
#
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
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
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
 
  


Reply


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


All times are GMT -5. The time now is 01:59 PM.

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