Kevin Schultz
Kevin Schultz

Reputation: 884

User input to set cal month and year in linux shell script

I am writing a shell script for a linux class and have been unable to determine how to apply the user input to the calendar. I am reading the month and year from the user and need to display the calendar with the indicated month and year.

I'm not sure how to make cal show the month and year entered? Any help would be awesome.

Upvotes: 1

Views: 1345

Answers (1)

Vorsprung
Vorsprung

Reputation: 34387

Does this example help?

#!/bin/bash
month=$1
year=`date +%Y`

cal $month $year

get the command line parameter to set the month

set the year with the date command

call cal

Upvotes: 1

Related Questions