Date List Shell script
Due: End of Friday Lab
Specifications by Ian!
Purpose:
Write a shell script to print the date of a pathname in yyyy/mm/dd
format by processing the output of the "ls" command and using
the previously-written Perl script "monthconv". See the Examples
for the exact output format.
Usage:
$ ./datelist pathname
- Pathname must be supplied. (Script must not run if it is
missing.)
- Assume current year is 1998 (in output of "ls" command).
- Only needs to handle pathnames in 1997 and 1998.
- Requires a script to convert character months to numeric months,
e.g. from Dec to 12 and from Feb to 2. Use the Perl script
that you wrote to do this conversion. Your Shell script will
call your Perl script to convert the months to numbers.
Examples:
$ ./datelist .profile
1998/9/17 09:45 .profile
$ ./datelist .
1998/12/17 12:24 .
$ ./datelist /usr/lib/t450
1997/7/16 /usr/lib/t450
$ ./datelist
./datelist: 1: parameter not set
Program Design:
Note the difference in "ls" date/time output for pathnames older than 12
months:
$ ls -ld .
drwxr-wr-x 2 ian 512 Dec 16 09:45 .
$ ls -ld /usr/lib/t450
-r-xr-xr-x 1 bin 12120 Jul 16 1997 /usr/lib/t450
The seventh field is different in the two output formats. Your script
must take note of this difference and still produce correct output.
You can assume that pathnames without years are in 1998.
(BONUS: Extract the actual current year from the output of "date".)
Hand In:
Hand in your Shell Script along with samples, similar to the Examples,
above, that show that your script can handle any pathname and any date in 1997 or 1998.
|