2022-02-10 22:06:57 +00:00
|
|
|
//go:build !solution
|
2020-02-12 22:25:12 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
2024-06-01 23:47:30 +00:00
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func LinesCountInFile(lines map[string]int, filename string) {
|
|
|
|
file, err := os.Open(filename)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
|
|
for scanner.Scan() {
|
|
|
|
line := scanner.Text()
|
|
|
|
lines[line]++
|
|
|
|
}
|
|
|
|
}
|
2020-02-12 22:25:12 +00:00
|
|
|
|
2024-06-01 23:47:30 +00:00
|
|
|
func main() {
|
|
|
|
filenames, lines := os.Args[1:], make(map[string]int)
|
|
|
|
for _, filename := range filenames {
|
|
|
|
LinesCountInFile(lines, filename)
|
|
|
|
}
|
|
|
|
for line, count := range lines {
|
|
|
|
if count != 1 {
|
|
|
|
fmt.Printf("%v\t%v\n", count, line)
|
|
|
|
}
|
|
|
|
}
|
2020-02-12 22:25:12 +00:00
|
|
|
}
|