-   Programming (
-   -   Unary Operator expected. Bash script (

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" ]
elif [ `cal $MTH $YR | tail +2 | grep -w $DAY | cut -c 4-5` = "$DAY" ]

- 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


The comparator should be == not =


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.