- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script - even or odd weeks
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
11-10-2003 12:41 AM
11-10-2003 12:41 AM
so simple like this:
if today = an even week do this
else
do that
fi
thanks in advance
Andi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 12:49 AM
11-10-2003 12:49 AM
Re: Script - even or odd weeks
date +%U
Regards,
Bernhard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 12:50 AM
11-10-2003 12:50 AM
Re: Script - even or odd weeks
test it if you can divide by 2
Rgds
JL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 12:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 12:56 AM
11-10-2003 12:56 AM
Re: Script - even or odd weeks
date +%w
the output is weekday as a one-digit decimal number [0-6 (Sunday-Saturday)].
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 12:59 AM
11-10-2003 12:59 AM
Re: Script - even or odd weeks
i confuse
week with weekday!!!!!
sorry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 01:01 AM
11-10-2003 01:01 AM
Re: Script - even or odd weeks
Jan-Luc and Christian are correct, to comply with DIN standards it should be %V (week 1 of the year is the first week containing a thursday, otherwise it still belongs to last year).
Regards,
Bernhard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 01:04 AM
11-10-2003 01:04 AM
Re: Script - even or odd weeks
date +%U and date +%V both return a week number, the first assumes the week starts on a Sunday, the second assumes Monday.
Pick the one which suits you and then do a simple modulo operation.
eg
#/bin/sh
w=$(date +%U)
(( even=$w % 2 ))
if [ $even -eq 0 ]
then
do this
else
do that
end if
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 01:05 AM
11-10-2003 01:05 AM
Re: Script - even or odd weeks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 01:28 AM
11-10-2003 01:28 AM
Re: Script - even or odd weeks
(the first day of the week is Monday, then all days that preceding the first Sunday of new year, are considered in week number 0)
date +%W
HTH
Bruno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2003 03:03 AM
11-10-2003 03:03 AM
Re: Script - even or odd weeks
if [[ $(( (($(caljd.sh) + 1) / 7) % 2) )) -eq 0 ]]
then
echo "Week is even"
else
echo "Week is odd"
fi
This will work whether there are 52 weeks or
53 weeks in the year.
We add 1 to the Julian Day (so that weeks start on Sunday), divide by 7 to get the week number and then a mod 2.