A collection of basic Unix command-line utilities implemented in Go. This project recreates fundamental Unix tools to help understand their inner workings and practice Go programming.
- Go 1.16 or higher must be installed on your system
- Basic knowledge of command-line operations
This project includes the following Unix utilities:
Lists all files and directories in the current working directory with color coding for executables.
Features:
- Lists all files in the current directory
- Color codes executable files in green for easy identification
- Displays regular files with standard formatting
Usage:
go run ls.goExample Output:
.git cat.go grep.go ls.go main.go test.txt ws.go
Note: Executable files will appear in green in the terminal
Reads and displays the complete content of a specified file.
Features:
- Reads any text file
- Displays content to standard output
- Error handling for missing or unreadable files
Usage:
go run cat.go <filename>Example:
go run cat.go test.txtExample Output:
first line for testing
second line for testing
third line for testing
fourth line for testing
fifth line for testing
Searches for a target string within a file and highlights matching occurrences.
Features:
- Searches for a specific string in a file
- Highlights matching text in red
- Word-based pattern matching
Usage:
go run grep.go <filename> <search_string>Example:
go run grep.go test.txt "testing"Example Output:
first line for testing
second line for testing
third line for testing
fourth line for testing
fifth line for testing
Note: Matching words will be highlighted in red in the terminal
Displays statistics about a file including the number of lines, words, and bytes.
Features:
- Counts the number of lines in a file
- Counts the total number of words
- Displays the file size in bytes
Usage:
go run ws.go <filename>Example:
go run ws.go test.txtExample Output:
Lines: 5
Words: 16
Bytes: 116
No installation is required. Simply clone the repository and run the utilities using go run:
git clone https://github.com/ashusevim/Unix-Utilities.git
cd Unix-UtilitiesUnix-Utilities/
├── ls.go # List directory contents utility
├── cat.go # Display file contents utility
├── grep.go # Search text in files utility
├── ws.go # Word statistics utility
├── main.go # (Currently unused)
└── test.txt # Sample test file
Each utility can be run independently using the go run command. Make sure you're in the project directory before running any commands.
- These utilities are simplified versions of their Unix counterparts
- They serve as educational implementations to understand basic file operations in Go
- Color coding in terminal output uses ANSI escape codes
Feel free to contribute by:
- Adding new Unix utilities
- Improving existing implementations
- Adding more features to current utilities
- Reporting bugs or suggesting enhancements
This project is open source and available for educational purposes.