My own implementation of the famous Unix command: ls, using the C programming language.
To be able to build and run this program you'll need a macbook, because I didn't make it portable for other systems. Sorry :(. As for software Requirements, you'll need:
- GNU make
- GCC
No specific versions, just update them to the latest version if you still can't build the program.
- Download/Clone the source code
cdinto the root directory- Run
make
Some macros may be modified in the header file ft_ls.h.
COLOUR, Forces on-Gmeaning that colours are always on.COLUMN, Forces on'xmeannig that columns are always displayed.
It's pretty simple, instead of calling ls, call ./ft_ls from the root directory of the source code after building it.
- Long listing display:
-l[MANDATORY] - Display recursively:
-R[MANDATORY] - Display all files:
-a[MANDATORY] - Reverse sort:
-r[MANDATORY] - Sort by modification date: -t [MANDATORY]
- Sort by last status change time:
-c - Directories are listed as plain files (not searched recursively):
-d - Output is not sorted. Forces
-aon:-f - List in long format but omit owner:
-g - Show serial number (inode number):
-i - List in long format but omit group:
-o - Display after pathname:
/directory:-p - Sort by time of last access:
-u - Displays columns horizontally sorted:
-x - List all entries except for
.and..:-A - Display after pathname:
/directory,*executable,@sym link,=socket,%whiteout,|FIFO:-F - Coloured output:
-G - (Not in the original ls) Displays number of files read:
-N - Sort by file size:
-S - Show time information in full:
-T - Sort by time of file creation:
-U - Force output to be one entry per line:
-1
- Displays all illegal options, instead of only 1 for the real ls.
- As you can see, lots of optional flags compared to the subject requirements.
- Access Control Lists (@ and + in file permissions).
- You can find the project instructions by clicking here
- I know comments would have been super useful, this is kind of a big code base, but I'm trying to go fast in my school program, I'll make sure to add them later.
- There are probably better ways to implement it, but we are limited by a set of functions at my school (just to make it harder and give us a deeper understanding of what's happening in the back), please, review the subject before you explain how
XorYwould have been a better way to do it ;)