- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: check date
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
Discussions
Discussions
Forums
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
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
тАО12-29-2008 08:16 PM
тАО12-29-2008 08:16 PM
if this month is Jan , May , July and today is last day of month ( 28th, 29th , 30th or 31th )
then do xxx
if this month is Feb , Mar , Aug and today is last day of month ( 28th, 29th , 30th or 31th )
then do yyy
end.
can advise how to write this script ? thx
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2008 11:45 PM
тАО12-29-2008 11:45 PM
Solutionhttp://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1158441
if [[ $(cal) = *$(date +%d) ]]; then # last day of month
case $(date $b) in
Jan|May|Jul) xxx;;
Feb|Mar|Aug) yyy;;
esac
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2008 01:24 AM
тАО12-30-2008 01:24 AM
Re: check date
I changed today as 31Dec and the script as below .
=================================
if [[ $(cal) = *$(date +%d) ]];
echo testing
case $(date $b) in
Jan|May|Jul) echo test1 ;;
Feb|Mar|Dec) echo test2 ;;
esac
fi
==================================
The output is "testing" only ,
I think it check today is last day , but do not recognize this month is Dec , can advise how to change it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2008 01:36 AM
тАО12-30-2008 01:36 AM
Re: check date
case $(date |awk '{ print $2 } ' ) in
Jan|May|Jul) echo test1 ;;
Feb|Mar|Dec) echo test2 ;;
esac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2008 02:07 AM
тАО12-30-2008 02:07 AM
Re: check date
Oops, a typo, $b vs %b:
if [[ $(cal) = *$(date +%d) ]]; then # last day of month
case $(date %b) in
Jan|May|Jul) test1;;
Feb|Mar|Aug) test2;;
esac
fi
>F Verschuren: The following will work for most shells
Why would you want to use awk(1) if date(1) will do the right thing, if you do it right. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2008 02:09 AM
тАО12-30-2008 02:09 AM
Re: check date
case $(date +%b) in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2008 02:43 AM
тАО12-30-2008 02:43 AM