Documentation
¶
Index ¶
Constants ¶
const ( // CutComplement inverts the selection: emit positions NOT in the set. CutComplement cutComplementFlag = true // CutNoComplement is the default: emit positions in the set. CutNoComplement cutComplementFlag = false )
Variables ¶
This section is empty.
Functions ¶
func Cut ¶
Cut returns a Command that selects fields, bytes, or characters from each input line, equivalent to the Unix cut(1) utility.
Modes (mutually exclusive, resolved in this order):
- CutBytes: select bytes by position (-b)
- CutChars: select characters (runes) by position (-c)
- CutFields (with CutDelimiter): select fields by position (-f/-d)
CutComplement inverts the selection for any mode. Specs accept comma-separated 1-based positions and ranges, including open-ended ranges: "1,3-5", "2-", "-3".
Types ¶
type CutBytes ¶
type CutBytes string
CutBytes selects bytes by position (-b flag). The spec string uses 1-based positions and ranges: "1-3,5,7-9".
type CutChars ¶
type CutChars string
CutChars selects characters (runes) by position (-c flag). The spec string uses 1-based positions and ranges: "1-3,5,7-9".
type CutDelimiter ¶
type CutDelimiter string
CutDelimiter sets the field delimiter (-d flag). Default is tab.
type CutFieldsOpt ¶
type CutFieldsOpt []CutField
CutFieldsOpt selects fields by 1-based position (-f flag).
func CutFields ¶
func CutFields(f ...CutField) CutFieldsOpt
CutFields returns a fields option for Cut.