Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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 started using Ubuntu recently and i wanned to write a little script, but i am not sure how to convert it into bash script.
I would like to display a monthly calendar using cal command. This should repeate as often as desired for different years and month till the user likes to exit the process. As soon as that happens the user has to be given an echo how to stop the prozess.
Do you have any idea how to write it as script? Please let me know, many thanks in advance!
Can you clarify the input and the output of your desired program? I.e. how does the user tell the program what they want.
A possible solution without writing a program: To output a certain month and year, for example December 2019, the user can just type cal 12 2019. When they want another month, they type cal anothermonth anotheryear. When they want to exit the process, they stop typing.
sounds like a learning curve. start with simple loops, and build up into how to break out of them, stop them from running, echo and read -p "text" var
Here's a freebe
Code:
#!/usr/bin/env bash
var=y
while [[ ${var^^} != 'N' ]]
do
read -p "enter month and year, mm/yyyy " date
cal $date
read -p "do you want to continue? Y/n " var
done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.