Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Hi, i was wondering how i can use the cal command so it displays the current month and the next month, i know you can use cal -3 9 2007 ...
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    4

    Help with bash

    Hi, i was wondering how i can use the cal command so it displays the current month and the next month, i know you can use cal -3 9 2007 to show the previous current and next but i just want to display the current and next. Thanks a lot!

  2. #2
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    358
    From the man page: cal -A 1
    -A number
    Display the number of months after the current month.

  3. #3
    Just Joined!
    Join Date
    Mar 2011
    Posts
    4
    I may be being stupid but when i type cal -A 2 it says that A is an invalid option, any ideas why?

  4. #4
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    39
    Quote Originally Posted by nippyeyes View Post
    I may be being stupid but when i type cal -A 2 it says that A is an invalid option, any ideas why?
    Well, maybe it's because it's the wrong option, if you look at the manual you can find this:

    Code:
    -m month
                 Display the specified month.  If month is specified as a decimal
                 number, it may be followed by the letter ‘f’ or ‘p’ to indicate
                 the following or preceding month of that number, respectively.

  5. #5
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    358
    "cal -A 1" gives me a calendar of two months, the current month and the next month. I have no idea why you would get an error. It should work. What distro are you running? Perhaps it's different for some distros.

  6. #6
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    The command cal on GNU/Debian testing (wheezy) accepts "-A". The command cal on GNU/Debian squeeze (stable) does not. Both man pages are marked March 14, 2009; the wheezy version describes "-A", the squeeze version does not.

    So, even within a specific distribution there are some differences between editions.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  7. #7
    Just Joined!
    Join Date
    Mar 2011
    Posts
    4
    I am currently using ubuntu, i thought maybe i could write a bash script and then execute it with ./filename in the terminal, does anyone have any ideas on what the bash scrip would contain, i tried simply writing cal 1 2010 + cal 2 2010 but this didnt work. Thank you

  8. #8
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.
    Quote Originally Posted by nippyeyes View Post
    ... i tried simply writing cal 1 2010 + cal 2 2010 but this didnt work ...
    try:
    Code:
    cal 1 2011 ; cal 2 2011
    Learning more about the command line (shell) would be useful ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  9. #9
    Just Joined!
    Join Date
    Mar 2011
    Posts
    4
    Thanks for the help, really appreciate it. Do you know any free e books where i can expand my knowledge?

  10. #10
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Many people recommend these two, and you can Google for more ... cheers, drl

    Bash Guide for Beginners

    Advanced Bash-Scripting Guide
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...