LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 11:23 AM   #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 11:36 AM.
 
Old 07-25-2008, 11:33 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 11:35 AM.
 
Old 07-25-2008, 01: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, 02: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:58 AM.

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
Open Source Consulting | Domain Registration