init
This commit is contained in:
commit
f7443bbab9
30 changed files with 271 additions and 0 deletions
11
dup3/hello
Normal file
11
dup3/hello
Normal file
|
@ -0,0 +1,11 @@
|
|||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
world
|
||||
world
|
||||
world
|
||||
world
|
||||
world
|
||||
hello
|
||||
hello
|
27
dup3/main.go
Normal file
27
dup3/main.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
counts := make(map[string]int)
|
||||
for _, filname := range os.Args[1:] {
|
||||
data, err := ioutil.ReadFile(filname)
|
||||
if err != nil {
|
||||
fmt.Fprint(os.Stderr, "dup3: %v\n", err)
|
||||
continue
|
||||
}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
counts[line]++
|
||||
}
|
||||
}
|
||||
for line, n := range counts {
|
||||
if n > 1 {
|
||||
fmt.Printf("%d\t%s\n", n, line)
|
||||
}
|
||||
}
|
||||
}
|
0
dup3/main.go~
Normal file
0
dup3/main.go~
Normal file
Reference in a new issue