![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fetching paragraphs with SED | ipat | Shell Programming and Scripting | 4 | 02-02-2009 11:38 AM |
| Fetching unique values from file | shivi707 | UNIX Desktop for Dummies Questions & Answers | 1 | 01-09-2009 08:33 AM |
| Problems fetching EMC disks to Solaris OS. | orac | SUN Solaris | 10 | 08-18-2008 07:58 AM |
| IMU sample fetching over RS485 | aloha_boi | High Level Programming | 0 | 07-23-2008 04:05 AM |
| fetching a web page in C | rayne | High Level Programming | 4 | 08-08-2007 10:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
shell script Code:
#!/bin/ksh
monthend()
{
if [[ -z "$1" ]] ; then
set -A arr $(cal | tail -3 | tr -s '\n' ' ')
else
set -A arr $(cal $1 $2| tail -3 | tr -s '\n' ' ')
fi
p=$(( ${#arr[*]} % 7 ))
element=0
case "$p" in
'0') element=$(( ${#arr[*]} - 2 ));;
'1') element=$(( ${#arr[*]} - 3 ));;
'2') element=$(( ${#arr[*]} - 1 ));;
'3') element=$(( ${#arr[*]} - 1 ));;
'4') element=$(( ${#arr[*]} - 1 ));;
'5') element=$(( ${#arr[*]} - 1 ));;
'6') element=$(( ${#arr[*]} - 1 ));;
esac
echo ${arr[element]}
}
# example current month monthend:
cal # show the calendar
monthend # print monthend
# for all of 2008
for i in 1 2 3 4 5 6 7 8 9 10 11 12
do
cal $i 2008
monthend $i 2008
done
#usage:
monthend | read thismonthend
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|