- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find every Thursday in a year?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 06:55 AM
10-12-2004 06:55 AM
Does anybody know how to get date or cal to show every Thursday in a year?
Thanks,
Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 06:58 AM
10-12-2004 06:58 AM
Re: Find every Thursday in a year?
http://www.hpux.ws/merijn/caljd-2.23.sh
http://www.hpux.ws/merijn/caljd-2.2.pl
You'll need to read the notes to learn how to give the tool input.
A. Clay's date magic tool!
It can do all kinds of date magic. Bookmark it, its updated periodically. I've ported it to Linux(shell change).
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 07:07 AM
10-12-2004 07:07 AM
Solution#!/usr/bin/sh
typeset PROG=${0##*/}
usage()
{
echo "\n${PROG}: year wkday\n" >&2
echo "year - 4-digit year" >&2
echo "wkday: 0 - Sun, 1 - Mon, ... 6 - Sat\n" >&2
return 255
} # usage
typeset -i STAT=0
if [[ ${#} -ge 2 ]]
then
typeset -i YR=${1}
typeset -i WKDAY=${2}
shift 2
typeset -i JDAY1=$(caljd.sh 1 1 ${YR})
typeset -i WDAY1=$(caljd.sh -w ${JDAY1})
typeset OFFSET=$((${WKDAY} - ${WDAY1}))
if [[ ${OFFSET} -lt 0 ]]
then
((OFFSET += 7))
fi
typeset -Z4 YEAR=${YR}
typeset -Z2 MONTH=0
typeset -Z2 DAY=0
typeset JD=$((${JDAY1} + ${OFFSET}))
while [[ ${YEAR} -eq ${YR} ]]
do
caljd.sh ${JD} | read MONTH DAY YEAR
if [[ ${YEAR} -eq ${YR} ]]
then
echo "${MONTH}/${DAY}/${YEAR}"
fi
((JD += 7))
done
else
usage
STAT=${?}
fi
exit ${STAT}
-------------------------------------------
Invoke it like this:
weekday.sh 2005 4
The trick is to find the 1st desired weekday in the year and then display every 7th day until the year changes. If I ain't done gone and typed something wrong, this here ought to do it for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 07:20 AM
10-12-2004 07:20 AM
Re: Find every Thursday in a year?
To be ultra nit-picky, please make these changes:
typeset OFFSET=$((${WKDAY} - ${WDAY1}))
to
typeset -i OFFSET=$((${WKDAY} - ${WDAY1}))
and
typeset JD=$((${JDAY1} + ${OFFSET}))
to
typeset -i JD=$((${JDAY1} + ${OFFSET}))
The script will work just fine w/o these changes but I tend to be a rigorous kind of guy. I didn't notice anything else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 08:40 AM
10-12-2004 08:40 AM
Re: Find every Thursday in a year?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2004 09:09 AM
10-12-2004 09:09 AM
Re: Find every Thursday in a year?
#!/bin/sh
# Input year
year=${1:-2004}
month=1
while [[ $month -le 12 ]]
do
cal $month $year | head -1
cal $month $year | grep -v $year | cut -b 12-14
let month=month+1
done
It will give you informations there.