Question: Write a C program myls whose behavior resembles that of the system command ls. myls must accept the following parameters: $ myls [-ars] [directory] If

Write a C program myls whose behavior resembles that of the system command ls. myls must accept the following parameters:

$ myls [-ars] [directory] 

If myls is provided with no parameters, it lists the names of all files in the current directory, one file name per line.

directory specifies the name of a directory, in which case myls lists the names of files within that directory.

-a switch forces myls to display the names of hidden files (whose names start with a "."). In the absence of this switch, hidden files are not listed.

-s switch sorts the filenames in alphabetical order.

-r switch sorts the filenames in the reverse alphabetical order

$ myls $ myls -a $ myls -as $ myls -ar

 

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!