A Go implementation of the cat
command used to concatenate file(s) and print the result to the terminal. This project replicates the functionality of the Unix cat
command with additional features.
- Concatenate and display files.
- Read from standard input if no files are provided or
-
is used. - Number all lines or non-blank lines.
- Suppress repeated empty lines.
- Display end-of-line characters.
- Show tab characters.
- Go 1.18 or higher
-
Clone the repository:
git clone https://github.com/AvaterClasher/gat cd gat
-
Build the project:
go build -o cat.exe
-
Add the directory containing
cat.exe
to your PATH:- Open the Start Search, type in "env", and select "Edit the system environment variables"
- In the System Properties window, click on the "Environment Variables" button
- In the Environment Variables window, highlight the "Path" variable in the "System variables" section and click the "Edit" button
- Click "New" and add the path to the directory containing
cat.exe
(e.g.,C:\path\to\cat-go
) - Click "OK" to close all windows
-
Verify the installation:
cat --version
cat [OPTIONS] [FILE]...
-n, --number
: Number all output lines-b, --number-nonblank
: Number non-blank output lines-s, --squeeze-blank
: Suppress repeated empty output lines-E, --show-ends
: Display$
at end of each line-T, --show-tabs
: Display TAB characters as^I
-
Basic Concatenation:
cat file1.txt file2.txt
-
Number All Lines:
cat --number file1.txt cat -n file1.txt
-
Number Non-Blank Lines:
cat --number-nonblank file1.txt cat -b file1.txt
-
Suppress Repeated Empty Lines:
cat --squeeze-blank file1.txt cat -s file1.txt
-
Display End-of-Line Characters:
cat --show-ends file1.txt cat -E file1.txt
-
Show Tab Characters:
cat --show-tabs file1.txt cat -T file1.txt
-
Combined Options:
cat --number --show-ends file1.txt cat -n -E file1.txt
-
Reading from Multiple Files:
cat file1.txt file2.txt
This project is licensed under the MIT License. See the LICENSE file for details.