ls: Implement ls in C
Overview and Goal
The goal of this task is to write your own implementation of the GNU/Linux ls
command in the C programming language.
Of course, not all the functionality of the original ls has to be
implemented: Your program must only behave like the original, invoked with -1
and -F. It must also support a single, optional parameter specifying the
file or directory to be listed. If this parameter is not given, the contents
of the current directory are listed. Otherwise, either the single file, or the
contents of the given directory are listed.
Expected Output
The program must have the exact same behavior as the GNU/Linux ls command
with the options -1 and -F.
Important: Directories are listed with / at the end, executable files with
* and symlinks with @! See man ls for more details.
The following is an example output of GNU/Linux ls:
$ ls -1 -F
ls*
ls.c
Makefile
[login to view URL]
symlink@
Invocation without Parameter
If invoked without any parameter, the contents of the current directory are
listed:
$ ./ls
ls*
ls.c
Makefile
[login to view URL]
symlink@
Invocation with Optional Directory
If a directory is given as parameter, its contents are listed:
$ ./ls ..
1-hello/
2-base64/
3-ls/
4-sort/
5-shell/
[login to view URL]
[login to view URL]
Invocation with Optional File
If a file is given as parameter, only the file is listed:
$ ./ls /etc/hostname
/etc/hostname
Evaluation
Total points possible: 5
Minimum number of points required to pass: 4
Points can be obtained as follows:
1 Point: Invocation without any parameter in any directory
1 Point: Invocation with any directory as parameter
1 Point: Invocation with any file as parameter
1 Point: Correct identification of directories ("/") and executables ("*")
1 Point: Correct identification of symlinks ("*")
the source has to compile with the attached makefile!
Hi, I have a professional experience of over 3 years working in C/C++ and have worked on projects related to system programming during my university tenure, have done pretty much similar tasks like this (creating custom shell and its commands). If interested, we can discuss the details.
€200 EUR en 4 jours
5,0 (4 commentaires)
1,9
1,9
2 freelances proposent en moyenne €140 EUR pour ce travail