LinuxQuestions.org
Review your favorite Linux distribution.
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 07-25-2008, 12:23 PM   #1
akeenabawa
LQ Newbie
 
Registered: Jul 2008
Distribution: Fedora Core 2, Ubuntu 8
Posts: 13

Rep: Reputation: 0
Question Bash Script to run on Modays


Hi, new to Linux. Trying to write a bash script that recognizes if it's Monday or not.
If [ Mon ]
then
do something
I have this:
If [ $(date) ('+%a'=Mon) ]
then
but I get these errors:
line 11: syntax error near unexpected token `('
line 11: `If [ $(date) ('%a'=Mon) ] '
Thanks

Last edited by akeenabawa; 07-25-2008 at 12:36 PM.
 
Old 07-25-2008, 12:33 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Linux is case sensitive. It looks like you used an upper-case "If" instead of the correct "if" (all lower-case). Furthermore the syntax is not correct. It should be
Code:
if [ $(date +%a) = Mon ]
then
Also, please use code tags to embed the lines of code in your posts: they will make the code more readable. To put code tags, you can go in advanced mode (see the button "Go Advanced" below), select the text you want to enclose in code tags and press the "#" button. Alternatively you can explicitly write [CODE] and [/CODE] before and after the text respectively.

Last edited by colucix; 07-25-2008 at 12:35 PM.
 
Old 07-25-2008, 02:29 PM   #3
xkero
Member
 
Registered: Dec 2007
Posts: 30

Rep: Reputation: 15
If this script has to be run every monday or on a predictable schedule I'd suggest using cron to run it (http://www.scrounge.org/linux/cron.html how-to).
 
Old 07-25-2008, 03:27 PM   #4
akeenabawa
LQ Newbie
 
Registered: Jul 2008
Distribution: Fedora Core 2, Ubuntu 8
Posts: 13

Original Poster
Rep: Reputation: 0
Thumbs up

Thank you very much for the help, it works great.
 
  


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
Run my bash script as a daemon. jaimese Linux - Newbie 12 02-10-2011 04:28 PM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 03:40 PM
Bash Script -- run two processes at once? 1veedo Programming 2 12-22-2007 10:40 PM
run files using BASH script kkpal Programming 2 11-02-2007 09:21 AM
how to run one bash script from within another? babag Programming 9 04-28-2005 01:12 AM


All times are GMT -5. The time now is 08:19 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration