Please explain what this code is doing

Hi,

Pls explain me what the below code is doing. specially meaning if -a while calling test function-

case $1 in
1) beg_dt=01; end_dt=07 ;;
2) beg_dt=08; end_dt=14 ;;
3)  beg_dt=15; end_dt=21 ;;
4) beg_dt=22; end_dt=28 ;;
5) beg_dt=29; end_dt=31  ;;
esac test \( `date +%w` -eq $2 -a `date +%d` -ge $beg_dt -a `date +%d` -le $end_dt  \)
RC=$?
exit $RC

Thanks,
Shailesh

The above line is a syntax error. Should be two lines.

esac
test \( `date +%w` -eq $2 -a `date +%d` -ge $beg_dt -a `date +%d` -le $end_dt  \)

The script takes two mandatory parameters and reurns an exit status of zero if all the criteria in the "test" match.
$1 is some sort of week number (1-5) dividing the month into 7-day periods starting on the first of the month. The script will misbehave with values outside this range.
$2 is a day-of-week number in unix form (0-6 where 0 is Sunday).

The purpose of the script is a bit of a mystery because "date +%w" is a day-of-the-week not week-number-in the month.

What is the purpose of -a in code?

It is the logical AND operator. See "man test" (though it is usually implemented in the shell).
In your example all three conditions must be true for the result of the whole "test" to be true.

The condition can be paraphrased in this syntactically incorrect way:

((date +%w` -eq $2) AND (`date +%d` -ge $beg_dt) AND (`date +%d` -le $end_dt))