Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2014Spring

01.13.14 - 05.11.14

Introduction to UNIX/Linux

CSCI1483

Tuesday Thursday
10:00 AM - 11:20 AM

Shell Scripting III

Extra Credit 1

Objective: Working with command line arguments

pastdue

Submit Your Solution

Extra Credit 1

Requirements

Script functions as described30 pts
Total30 pts

Instructions

Create a shell script called show_seconds_for in your bin directory that will accept an amount of time as command line arguments and will then report the number of seconds in that amount of time.

This script should require 2 command line arguments and should report an error if 2 arguments are not given. The first argument should be a number and the second argument must be "second", "seconds", "minute", "minutes", "hour", or "hours".

The user should execute the script with a command like:

show_seconds_for 14 minutes

show_seconds_for 34 seconds

or

show_seconds_for 2 hours

The script should, based on the arguments given, calculate how many seconds are in each time period specified. For example, if "34 seconds" are the arguments the output from the script should be "34 seconds", if the arguments are "2 hours" the output from the script should be "7200 seconds"