
A lightweight C implementation of Unix utilities (grep/tail/cat)
An evolving collection of Unix command-line utilities written in C, focused on low-level I/O, memory management, and systems programming.
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
An evolving collection of Unix command-line utilities written in C, focused on low-level I/O, memory management, and systems programming.
This project aims to recreate commonly used Unix commands from scratch to gain a deeper understanding of how they work internally.
A custom implementation of the Unix cat command.
| Command | Description | | cat | Read from standard input and print to standard output. | | cat | Display the contents of a file. | | cat -n | Display file contents with line numbers. | | cat -e | Display $ at the end of each newline-terminated line. |
./cunix cat ./cunix cat file.txt ./cunix cat -n file.txt ./cunix cat -e file.txt
grep
A custom implementation of the Unix grep command for searching text within files.
| Command | Description | | grep | Search for a substring and print matching lines. | | grep | Search for a substring across multiple files. | | grep -n | Display matching lines prefixed with their line numbers. | | grep -v | Print lines that do not match. | | grep -c | Print the number of matching lines. | | grep -q | Don't print anything; indicate whether a match exists through exit status |
./cunix grep hello file.txt ./cunix grep error log1.txt log2.txt ./cunix grep "hello world" file.txt ./cunix grep -n "test" file.txt ./cunix grep -v "test" file.txt ./cunix grep -c "test" file.txt ./cunix grep -q "test" file.txt
tail
A custom implementation of the Unix tail command using backward file scanning.
| Command | Description | | tail | Display the last 10 lines of a file. | | tail -n | Display the last N lines of a file. | | tail | Display the last 10 lines of multiple files with filename headers. | | tail -n | Display the last N lines of multiple files with filename headers. |
./cunix tail file.txt ./cunix tail -n 5 file.txt ./cunix tail -n 20 large_file.txt ./cunix tail file1.txt file2.txt ./cunix tail -n 5 file1.txt file2.txt
Project Structure
All commands are accessible through the cunix executable:
./cunix <command> [options] [arguments]
Project Status
Work in Progress
The project is actively being developed. Additional Unix commands, options, error handling improvements, and tests will be added progressively.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。