mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-11-09 20:59:49 +03:00
150105f93f
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.
10 lines
291 B
Plaintext
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*$'
|
|
|
|
}
|
|
}
|