Other *NIXThis forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to create a calendar (on the fly) that will display next month.
I'm not talking about June 2010 (although since this is may that is next month). I want to have a script that will display a calendar for next month no matter when it is run.
If it is run in February, it will create a calendar for March.
If it is run in June, it will create a calendar for July.
If it is run in December, it will create a calendar for January.
I have tried:
Code:
cal -m `date +"%m"`
but it doesn't like that format (I'm assuming because of the leading zero.
Although that works on Linux, it doesn't seem to work on my Mac where I had intended on using it.
I was hoping there wouldn't be a difference but apparently there is.
Anyway to do this on a Mac?
(Yes, I realize this is LINUXQUESTIONS and not MACQUESTIONS but I can hope for an answer right?)
Not knowing how or why it's failing on your Mac I cannot answer this.
But I'm moving the question over to "Other *Nix" since it doesn't
belong here for obvious reasons.
Break the problem down into two parts. First, you need to focus on getting the numeric value for next month returned. Then you need to feed that value to the cal(1) command.
I won't have access to my OSX box until later today, but this may help in the meantime. (Or, it may be totally useless.)
Code:
# uname
FreeBSD
# date -v+1m +%m
06
If your date(1) program honors those precise options and formatting, you should be in business. If not, I'll check OSX later.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.