1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00
nu_scripts/stdlib-candidate-archive/std-rfc/tables/select-column-ranges.nu
Douglas 5869e0b529
Deprecate the nu_scripts version of stdlib-candidate (#1042)
Deprecates the existing `stdlib-candidate` directories in `nu_scripts`
since `std-rfc` has now transitioned to the main repo. Updates readme
and renamed directories.
2025-02-09 14:34:40 -06:00

20 lines
No EOL
1.3 KiB
Text

use ./col-indices.nu *
# Select a range of columns by their indices
#
# Example:
#
# ls -l | select column-ranges 0 10..12 | first 3
# # => ╭───┬────────────────────┬──────────────┬─────────────┬──────────────╮
# # => │ # │ name │ created │ accessed │ modified │
# # => ├───┼────────────────────┼──────────────┼─────────────┼──────────────┤
# # => │ 0 │ CITATION.cff │ 3 months ago │ 4 hours ago │ 3 months ago │
# # => │ 1 │ CODE_OF_CONDUCT.md │ 7 months ago │ 4 hours ago │ 7 months ago │
# # => │ 2 │ CONTRIBUTING.md │ 3 months ago │ 4 hours ago │ 3 months ago │
# # => ╰───┴────────────────────┴──────────────┴─────────────┴──────────────╯
export def "select column-ranges" [
...ranges
] {
let column_selector = ($in | col-indices ...$ranges)
$in | select ...$column_selector
}