mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 17:00:32 +03:00
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:
parent
20a297be73
commit
150105f93f
9
modules/wc/wc.nu
Normal file
9
modules/wc/wc.nu
Normal 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*$'
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user