A simple implementation of tail
command from Linux in Go.
It can be used to display the last few lines or bytes of a file.
It supports reading multiple files concurrently and offer options
to specify the number of lines or bytes to display.
- Display the last
n
lines orc
bytes of a file. - Read multiple files concurrently.
- Clone the repository:
git clone [email protected]:agkmw/go-tail.git cd go-tail
- Build the program:
go build
- Build the program with different name (
<filename>.exe
on Windows):go build -o <filename>
- Or install the executable to run it anywhere on your system:
go install
./go-tail [OPTIONS] <filename>
-n <number>
: Display the last <number>
of lines.
-c <number>
: Display the last <number>
of bytes.
+<number>
: Display from the <number>th
line or byte onward.
- Display the last 10 lines of a file (default):
./go-tail file.txt
- Display the last 20 lines of a file:
./go-tail -n 20 file.txt
- Display the last 50 bytes of a file:
./go-tail -c 50 file.txt
- Display from the 5th line onward:
./go-tail -n +5 file.txt
- Display multiple files:
./go-tail file.txt file2.txt file3.txt