Documentation ¶
Index ¶
- Variables
- func Columns(delimiter string, columns string) func(io.Reader, io.Writer) error
- func ColumnsCSV(delimiter string, columns string) func(io.Reader, io.Writer) error
- func CountLines() func(io.Reader, io.Writer) error
- func CountRunes() func(io.Reader, io.Writer) error
- func CountWords() func(io.Reader, io.Writer) error
- func First(n int) func(io.Reader, io.Writer) error
- func Frequency() func(io.Reader, io.Writer) error
- func Join(delimiter string) func(io.Reader, io.Writer) error
- func Last(n int) func(io.Reader, io.Writer) error
- func Match(substring string) func(io.Reader, io.Writer) error
- func MatchRegex(regex *regexp.Regexp) func(io.Reader, io.Writer) error
- func NewPipeline(r io.Reader) *pipeline
- func NotFirst(n int) func(io.Reader, io.Writer) error
- func NotLast(n int) func(io.Reader, io.Writer) error
- func NotMatch(substring string) func(io.Reader, io.Writer) error
- func NotMatchRegex(regex *regexp.Regexp) func(io.Reader, io.Writer) error
- func Replace(old, replace string) func(io.Reader, io.Writer) error
- func ReplaceRegex(regex *regexp.Regexp, replace string) func(io.Reader, io.Writer) error
Constants ¶
This section is empty.
Variables ¶
var ( Filters = map[string]reflect.Value{ "columns": reflect.ValueOf(Columns), "columnscsv": reflect.ValueOf(ColumnsCSV), "countlines": reflect.ValueOf(CountLines), "countrunes": reflect.ValueOf(CountRunes), "countwords": reflect.ValueOf(CountWords), "first": reflect.ValueOf(First), "!first": reflect.ValueOf(NotFirst), "frequency": reflect.ValueOf(Frequency), "join": reflect.ValueOf(Join), "last": reflect.ValueOf(Last), "!last": reflect.ValueOf(NotLast), "match": reflect.ValueOf(Match), "!match": reflect.ValueOf(NotMatch), "matchregex": reflect.ValueOf(MatchRegex), "!matchregex": reflect.ValueOf(NotMatchRegex), "replace": reflect.ValueOf(Replace), "replaceregex": reflect.ValueOf(ReplaceRegex), } )
Functions ¶
func Columns ¶
Columns returns a filter that writes the selected 'columns' in the order provided where 'columns' is a 1-indexed comma separated list of column positions. Columns are defined by splitting with the 'delimiter'.
func ColumnsCSV ¶ added in v0.1.2
ColumnsCSV returns a CSV aware filter that writes the selected 'columns' in the order provided where 'columns' is a 1-indexed comma separated list of column positions. Columns are defined by splitting with the 'delimiter'.
func CountLines ¶
CountLines returns a filter that writes the number of lines read.
func CountRunes ¶
CountRunes returns a filter that writes the number of runes (utf8 characters) read.
func CountWords ¶
CountWords returns a filter that writes the number of words (as defined by strings.Fields()) read.
func Frequency ¶
Frequency returns a filter that writes unique lines from the input, prefixed with a frequency count, in descending numerical order (most frequent lines first). Lines with equal frequency will be sorted alphabetically.
This is a common pattern in shell scripts to find the most frequently-occurring lines in a file:
sort testdata/freq.input.txt |uniq -c |sort -rn
Frequency's behaviour is like the combination of Unix `sort`, `uniq -c`, and `sort -rn` used here.
Like `uniq -c`, Freq left-pads its count values if necessary to make them easier to read:
10 apple 4 banana 2 orange 1 kumquat
func Join ¶
Join returns a filter that writes all lines as a single string separated by 'delimiter'.
func MatchRegex ¶
MatchRegex returns a filter that writes lines matching the compiled regular expression 'regex'.
func NewPipeline ¶
NewPipeline returns new pipeline given a io.Reader.
func NotMatchRegex ¶
NotMatchRegex returns a filter that writes lines not matching the compiled regular expression 'regex'.
Types ¶
This section is empty.