[cs631apue] handling multiple command options

mseaton mseaton at stevens.edu
Sun Oct 9 16:54:04 EDT 2016

I'm not sure I understand.  The ls(1) command you're implementing does
not have any flags that accept a filename as a specific argument for
just that flag.  After all command-line options are processed, the
remaining arguments are to be treated as pathnames, which need to be

Hello Prof Schaumann,
What I mean is, the user may wish not to type any of the command 
options. If the user types ls dirname, then it should go into dirname 
and print all files in this directory. If multiple filenames of any type 
are entered then it will display their names in alphabetical order for 
non-directories first before displaying directory contents.

So I have written a function that handles all outputs of this form only. 
In another function I have written handles all of the command options 
listed in the man pages, AaCc.... This is where I am using getopt. 
Eventually the two functions will have to work together to handle things 

ls -l dirname, etc. Does this make sense?

Thanks for your earlier response I will soon be working on getopt to 
hopefully get it to work for multiple options like la, etc.


More information about the cs631apue mailing list