From 150105f93f24b6542913fc34f2774b1c34ec9bd9 Mon Sep 17 00:00:00 2001 From: Sam Vente Date: Sun, 1 Oct 2023 00:14:19 +0200 Subject: [PATCH] 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. --- modules/wc/wc.nu | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 modules/wc/wc.nu diff --git a/modules/wc/wc.nu b/modules/wc/wc.nu new file mode 100644 index 0000000..4999261 --- /dev/null +++ b/modules/wc/wc.nu @@ -0,0 +1,9 @@ +export def main [...rest] { + let stdin = $in + if ($rest | length ) > 0 { + ^wc $rest | lines | parse -r '^\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*(?.*)$' + } else { + $stdin | ^wc | lines | parse -r '^\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*$' + + } +}