nu_scripts/modules/wc/wc.nu
Sam Vente 150105f93f
Add gnu wc wrapper (#625)
Wasn't quite sure where to place this, if anyone has a better place for
it please let me know. It's a nice wrapper around the gnu `wc` command
that gives you named columns back. Nice imo, since I always forget which
number means which.
2023-09-30 17:14:19 -05:00

10 lines
291 B
Plaintext

export def main [...rest] {
let stdin = $in
if ($rest | length ) > 0 {
^wc $rest | lines | parse -r '^\s*(?<lines>\d+)\s*(?<words>\d+)\s*(?<bytes>\d+)\s*(?<file>.*)$'
} else {
$stdin | ^wc | lines | parse -r '^\s*(?<lines>\d+)\s*(?<words>\d+)\s*(?<bytes>\d+)\s*$'
}
}