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.
This commit is contained in:
Sam Vente 2023-10-01 00:14:19 +02:00 committed by GitHub
parent 20a297be73
commit 150105f93f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

9
modules/wc/wc.nu Normal file
View File

@ -0,0 +1,9 @@
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*$'
}
}