Help with filtering dates from the calendar

Hi,

I need a simple shell script to help filter weekends from the calendar of a month. In other words, i need a script to identify the working days in a month.

#/bin/ksh
days=$( cal | sed -n '3,$p' | tr -s '\n' ' ')
offset=$(cal | awk 'NR==3 {print NF}' )
for i in $days
 do
    d=$(( ($i + $offset) % 7 ))     
    [[ $d -gt 0 ]] && [[ $d -lt 6 ]] && printf "%s " $i
 done    
 echo ""

try this.

Month=10
Year=2010
cal $Month $Year |cut -c4-17 |awk 'NR>2 {for (i=1;i<=NF;i++) printf $i FS} END {print}'

1 4 5 6 7 8 11 12 13 14 15 18 19 20 21 22 25 26 27 28 29

$ cal $Month $Year
   October 2010
 S  M Tu  W Th  F  S
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

Both works great, many thanks. :slight_smile:

---------- Post updated at 11:49 AM ---------- Previous update was at 11:48 AM ----------

I'm a newbie to shell scripting, can you point me to good resources for learning AWK and SED tools...