LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-22-2006, 01:45 PM   #1
Blackout_08
Member
 
Registered: Jan 2004
Posts: 35

Rep: Reputation: 15
Unary Operator expected. Bash script


I got this error with my script and I can't seem to figure out the problem.

./age.bash: line 202: [: =: unary operator expected

Here is a portion of my script

if [ `cal $MTH $YR | tail +2 | grep -w $DAY | cut -c 1-2` = "$DAY" ]
then
DAYOFWEEK=7
elif [ `cal $MTH $YR | tail +2 | grep -w $DAY | cut -c 4-5` = "$DAY" ]
then
DAYOFWEEK=1



- Now MTH equals the month and YR equals the yr.. u get the pt. I want to check to see what day of the week a person is born on (sun-sat). This is bash scripting btw.
 
Old 06-22-2006, 02:20 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

The comparator should be == not =

Dave
 
Old 06-22-2006, 02:21 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,293
Blog Entries: 54

Rep: Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855Reputation: 2855
What you should do is "sh -x age.bash 2>&1 | tee age.tee".
Now all variables are expanded and readable in age.tee.
Should make errors easier to spot.
 
  


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
bash equivalent to C increment operator andrewb758 Linux - General 5 02-21-2009 12:25 PM
Users' bash prompt not as expected (Mandriva 2006) conn-fused Mandriva 4 02-28-2006 03:27 AM
shell script provides an error that a binary operator is required max_rsr Linux - General 1 03-12-2005 08:26 AM
bash script and the , operator xviddivxoggmp3 Programming 1 08-14-2004 12:33 AM
Script Problem - Does not give expected results Jose Muņiz Linux - General 3 07-12-2003 10:10 PM


All times are GMT -5. The time now is 07:22 AM.

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