LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-08-2019, 03:37 PM   #1
T3Q1la
LQ Newbie
 
Registered: Nov 2019
Posts: 1

Rep: Reputation: Disabled
Smile creating continuous calendar with bash


Hello guys,

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!
 
Old 11-08-2019, 05:28 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
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.
 
1 members found this post helpful.
Old 11-08-2019, 10:30 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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

Last edited by BW-userx; 11-08-2019 at 10:38 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Continuous Integration/Continuous Development with FOSS Tools LXer Syndicated Linux News 0 08-01-2019 05:41 AM
LXer: Continuous Delivery and Continuous Deployment: Keys to the DevOps Revolution LXer Syndicated Linux News 0 04-17-2019 06:21 PM
LXer: Zuul: Proven open-source continuous integration/continuous delivery LXer Syndicated Linux News 0 05-23-2018 08:31 PM
LXer: Perfecting DevOps Continuous Integration and Continuous Delivery with Kayenta LXer Syndicated Linux News 0 04-11-2018 12:42 AM
prompt based calendar program? Calendar? thebeaglebeagle Linux - Software 0 09-15-2003 01:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration