GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script question
Operating System - HP-UX
1850467
Members
2413
Online
104054
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
09-03-2003 02:06 AM
09-03-2003 02:06 AM
Hi
Can anybody tell me how to determine from a day of the week output, how I may classify this as an A cycle, B cycle or C cycle assuming each cycle is of duration 7 days ?
Can anybody tell me how to determine from a day of the week output, how I may classify this as an A cycle, B cycle or C cycle assuming each cycle is of duration 7 days ?
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2003 02:14 AM
09-03-2003 02:14 AM
Solution
date +%j will tell you the day number in the year
% is the modulus operator
#!/sbin/sh
TODAY=$(date +%j)
let CYCLE=$TODAY%21
case $CYCLE in
0|1|2|3|4|5|6) echo "Cycle A";;
7|8|9|10|11|12|13) echo "Cycle B";;
14|15|16|17|18|19|20) echo "Cycle C";;
esac;
The only problem in on year-change, since the count is resetted to 0.
But maybe you can cope with it, or write additional code to keep track of the last cycle and change the script itself.
Massimo
% is the modulus operator
#!/sbin/sh
TODAY=$(date +%j)
let CYCLE=$TODAY%21
case $CYCLE in
0|1|2|3|4|5|6) echo "Cycle A";;
7|8|9|10|11|12|13) echo "Cycle B";;
14|15|16|17|18|19|20) echo "Cycle C";;
esac;
The only problem in on year-change, since the count is resetted to 0.
But maybe you can cope with it, or write additional code to keep track of the last cycle and change the script itself.
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2003 02:17 AM
09-03-2003 02:17 AM
Re: Script question
Hi Jeff,
Could you elaborate a bit more on what you are trying to achieve. I don't fully understand.
Cheers,
Tim
Could you elaborate a bit more on what you are trying to achieve. I don't fully understand.
Cheers,
Tim
Yesterday is history, tomorrow is a mystery, today is a gift. That's why it's called the present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2003 02:39 AM
09-03-2003 02:39 AM
Re: Script question
Hi Tim
I have a script caljd which calculates the julian day :-
caljd.sh -D -p 1
02
so day_of_week='caljd.sh -D -p 1' gives 02.
From this I need to use a case statement similar to that of Massimo to determine if this is cycle A B or C.
Jeff
I have a script caljd which calculates the julian day :-
caljd.sh -D -p 1
02
so day_of_week='caljd.sh -D -p 1' gives 02.
From this I need to use a case statement similar to that of Massimo to determine if this is cycle A B or C.
Jeff
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP