A minimal rewrite of the Unix ls command in C. Implements default directory listing and the -a flag in ~30 lines, no external dependencies.
gcc -Wall -Wextra -o myls ls.c
./myls
./myls /etc
./myls -a
./myls -a /etc- Default listing — hides dot files
-aflag — shows everything including hidden files- Error handling for invalid paths
- Defaults to current directory if no path is given
The real ls is ~5000 lines. This covers none of that. If you want to go further, look into stat() for implementing -l.