Question: Requirements You must write a Perl program that will provide a listing of files in a directory. The files must be listed in sorted order

Requirements

You must write a Perl program that will provide a listing of files in a directory. The files must be listed in sorted order by the filename.

By default, the program displays only filenames.

By default, the program lists the files in the currentdirectory.

The program must provide the following command line options to theuser:

-d [directory]: This option allows the user to specify a directory or no directory name. If the -d option is provided without specifying a directory name, list your current directory (~student user name/itec400/homework). The output shall be displayed using the following columnheaders:

File Name Size Owner Group

-l: This option instructs the program to display a long listing. The output shall display the following columnheaders:

File Name Size Owner Group

The user selects no options. List the file names under your current directory (~student user name/itec400/homework). The output shall display the following columnheader:

File Name

The script must be able to execute oncs.franklin.edu

The script file name must be:listdir.pl

The script must be located in$HOME/itec400/homework

Make sure the permissions on the your itec400 directory are 705

Make sure the permissions on your script are705

Sample Output

User selects no options (provide column header and list filenames):

> listdir.pl

File Name

4th

4th_log

4th.old

4th.old.2

address.cpp

address.h

address.o

User selects -l option (only subset of output isshow):

> listdir.pl -l

File Name Size Owner Group

OUTPUT HERE

User selects -d option.

> listdir.pl d

File Name Size Owner Group

OUTPUT HERE

User selects -d option without specifying a directoryname.

> listdir.pl d

File Name Size Owner Group

OUTPUT HERE

User selects -l and -d option (./listdir.pl l d )

> listdir.pl -l -d

/export/home/dandrear/temp OUTPUT HERE

User selects -d and -l option (illegalcombination):

> listdir.pl -d l

Standard output:

Usage: listdir.pl [-d directoryname][-l]

listdir.pl [-l] [-d directory name]

listdir.pl [-ddirectory]listdir.pl [-d]

listdir.pl [-l]NOTE: All other options are invalid for usage.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!