LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Unary Operator expected. Bash script (https://www.linuxquestions.org/questions/programming-9/unary-operator-expected-bash-script-457322/)

Blackout_08 06-22-2006 01:45 PM

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.

ilikejam 06-22-2006 02:20 PM

Hi.

The comparator should be == not =

Dave

unSpawn 06-22-2006 02:21 PM

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.


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