Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Head = &cli.Command{ Name: "head", Usage: "Display the first lines of a file", Flags: []cli.Flag{ &cli.IntFlag{Name: "lines", Aliases: []string{"n"}, Value: 10, Usage: "Number of lines"}, }, Action: func(ctx context.Context, cmd *cli.Command) error { n := cmd.Int("lines") files := cmd.Args().Slice() if len(files) == 0 { return printLines(os.Stdin, n, true) } for _, file := range files { f, err := os.Open(file) if err != nil { return fmt.Errorf("head: %s: %v", file, err) } if err := printLines(f, n, true); err != nil { f.Close() return err } f.Close() } return nil }, }
View Source
var Tail = &cli.Command{ Name: "tail", Usage: "Display the last lines of a file", Flags: []cli.Flag{ &cli.IntFlag{Name: "lines", Aliases: []string{"n"}, Value: 10, Usage: "Number of lines"}, }, Action: func(ctx context.Context, cmd *cli.Command) error { n := cmd.Int("lines") files := cmd.Args().Slice() if len(files) == 0 { return printLines(os.Stdin, n, false) } for _, file := range files { f, err := os.Open(file) if err != nil { return fmt.Errorf("tail: %s: %v", file, err) } if err := printLines(f, n, false); err != nil { f.Close() return err } f.Close() } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.