group-by
for filters> group-by {flags} (grouper)
grouper
: the path to the column to group oninput | output |
---|---|
list<any> | record |
Group items by the "type" column's values
>ls|group-bytype
Group items by the "foo" column's values, ignoring records without a "foo" column
>opencool.json|group-byfoo?
Group using a block which is evaluated against each input value
> [foo.txtbar.csvbaz.txt] |group-by { path parse|getextension }
╭─────┬─────────────────╮
││╭───┬─────────╮│
│txt││0│foo.txt││
│││1│baz.txt││
││╰───┴─────────╯│
││╭───┬─────────╮│
│csv││0│bar.csv││
││╰───┴─────────╯│
╰─────┴─────────────────╯
You can also group by raw values by leaving out the argument
> ['1''3''1''3''2''1''1'] |group-by
╭───┬───────────╮
││╭───┬───╮│
│1││0│1││
│││1│1││
│││2│1││
│││3│1││
││╰───┴───╯│
││╭───┬───╮│
│3││0│3││
│││1│3││
││╰───┴───╯│
││╭───┬───╮│
│2││0│2││
││╰───┴───╯│
╰───┴───────────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/group-by.html