https://github.com/marob05/unixutils
A series of projects where I implement Unix utilities in C from scratch. Additionally I explore various implementations (if possible)
https://github.com/marob05/unixutils
cprogramming-language linux unix utilities
Last synced: 22 days ago
JSON representation
A series of projects where I implement Unix utilities in C from scratch. Additionally I explore various implementations (if possible)
- Host: GitHub
- URL: https://github.com/marob05/unixutils
- Owner: MaroB05
- Created: 2024-11-08T16:33:03.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-24T12:10:16.000Z (about 2 months ago)
- Last Synced: 2025-03-30T20:33:20.408Z (about 2 months ago)
- Topics: cprogramming-language, linux, unix, utilities
- Language: C
- Homepage:
- Size: 2.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# myUNIX Utilities
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.## Utilities
### mcat
A minimal implementation of the `cat` command, which reads and displays the contents of one or more files.
Multiple implementations presented with performance enhancemenets.### mgrep
A simple implementation of the `grep` command, which searches for a pattern in one or more files and displays the matching lines.### mzip & munzip
A simple implementation of `zip` and `unzip` compression utilities, using the [Run-length Encoding](https://en.wikipedia.org/wiki/Run-length_encoding) Algorithm.### mcp
Implementing Unix's cp allowing you to copy files.
* Multiple implementations are presented:
- standard `read()` and `write()`
- `sendfile` system call.
- use `fallocate()` to pre-allocate file blocks on disk.### pwd
Implementation of pwd for printing the current directory.### helperFunctions
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.
## Usage
### mcat
* 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.### mgrep
* Compile: `gcc ../helperFunctions/functions.c grep.c -o mgrep`
* Run: `./mgrep pattern file1 file2 ...`### mzip
* Compile: `make compile`
* Run: `./build/mzip.out file`### munzip
* Compile: `make compile`
* Run: `./build/munzip.out file`### mcp
* Compile: `make compile`
* Run: `./build/mcp.out src dist`## Note
Benchmarks are done using a tool I have been developing called [`Bentest`](https://github.com/MaroB05/Bentest) for performance measurement## Contributing
Contributions are welcome! If you'd like to add a new utility or improve an existing one, please submit a pull request.## License
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).