diff --git a/lang-guide/chapters/filters/select-get.md b/lang-guide/chapters/filters/select-get.md index 746d61ee0d7..6fd6a6a2cf2 100644 --- a/lang-guide/chapters/filters/select-get.md +++ b/lang-guide/chapters/filters/select-get.md @@ -1,3 +1,33 @@ # Understanding the difference between `get` and `select` -TODO +### Get + +Extract data using a cell path. + +This is equivalent to using the cell path access syntax: `$env.OS` is the same as `$env | get OS`. + +If multiple cell paths are given, this will produce a list of values. + +```nu +'{"name":"Alice","job":"Engineer"}' +| from json +| get name +| describe +# => string +``` + +### Select + +Select only these columns or rows from the input. Opposite of `reject`. + +This differs from `get` in that, rather than accessing the given value in the data structure, it removes all non-selected values from the structure. + +Hence, using `select` on a table will produce a table, a list will produce a list, and a record will produce a record. + +```nu +'{"name":"Alice","job":"Engineer"}' +| from json +| select name +| describe +# => record +```