mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-30 13:47:46 +00: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
1 changed files with 9 additions and 0 deletions
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…
Add table
Add a link
Reference in a new issue