A collection of simple UNIX utilities implemented in C. The goal of this series of mini projects is to explore the C Programming Language, hence we may explore multiple approaches to the same task.
A minimal implementation of the cat
command, which reads and displays the contents of one or more files.
Multiple implementations presented with performance enhancemenets.
A simple implementation of the grep
command, which searches for a pattern in one or more files and displays the matching lines.
A simple implementation of zip
and unzip
compression utilities, using the Run-length Encoding Algorithm.
Implementing Unix's cp allowing you to copy files.
- Multiple implementations are presented:
- standard
read()
andwrite()
sendfile
system call.- use
fallocate()
to pre-allocate file blocks on disk.
- standard
Implementation of pwd for printing the current directory.
A library of helper functions which we develop as we go on, which is used by the above utilities, providing functionality for file I/O, string manipulation, and more.
- Compile:
gcc ../helperFunctions/functions.c mcat.c -o mcat
- Run:
./mcat file1 file2 ...
- Multiple implementations are presented, with the best of them mcat4 which performs around 13% faster than standard unix cat.
- Compile:
gcc ../helperFunctions/functions.c grep.c -o mgrep
- Run:
./mgrep pattern file1 file2 ...
- Compile:
make compile
- Run:
./build/mzip.out file
- Compile:
make compile
- Run:
./build/munzip.out file
- Compile:
make compile
- Run:
./build/mcp.out src dist
Benchmarks are done using a tool I have been developing called Bentest
for performance measurement
Contributions are welcome! If you'd like to add a new utility or improve an existing one, please submit a pull request.
This project is licensed under the MIT License.