https://github.com/flatfisher/go-head
head command in Go lang.
https://github.com/flatfisher/go-head
go golang
Last synced: 5 months ago
JSON representation
head command in Go lang.
- Host: GitHub
- URL: https://github.com/flatfisher/go-head
- Owner: flatfisher
- Created: 2018-04-05T12:46:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-08T11:58:48.000Z (over 8 years ago)
- Last Synced: 2024-12-30T22:29:29.661Z (over 1 year ago)
- Topics: go, golang
- Language: Go
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-head
head command in Go lang.
## 使い方(go runで実行)
- test.txtの中身を表示(デフォルト10)
```
$ go run head.go test.txt
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10
```
- 複数ファイルも対応
```
$ go run head.go test.txt test.txt
==> test.txt <==
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10
==> test.txt <==
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10
```
- test.txtの中身を15(n)行名まで表示
```
$ go run head.go -n 15 test.txt
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10
row11
row12
row13
row14
row15
```
- 複数ファイルも対応
```
$ go run head.go -n 3 test.txt test.txt
==> test.txt <==
row1
row2
row3
==> test.txt <==
row1
row2
row3
```
- test.txtの行数を表示(中身は表示されない)
```
$ go run head.go -s test.txt
test.txt has 20 lines
```
## テスト
```
$ go test
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10
PASS
ok _/Users/flatfisher/Documents/git/go-head 0.006s
```